Skip to content

Commit 0955e9d

Browse files
spnettecclaude
andcommitted
fix: apply upstream bug fixes and resource leak patches from apache/plc4x
- fix(s7): S7HMuxImpl direct buffer leak per-message (PR apache#2542) - fix(s7): alarm-query directBuffer not released in S7ProtocolLogic and S7NonHProtocolLogic (PR apache#2543) - fix(s7,spi): decodeLargeReadResponse heap buffer not released in S7ProtocolLogic and S7NonHProtocolLogic - feat(spi): SharedExecutor — JVM-scoped thread pools replace per-connection ThreadPoolExecutors to prevent thread accumulation on reconnect (PR apache#2281) - fix(spi): RequestTransactionManager.shutdown() cancels in-flight requests without shutting down shared executor - feat(spi): channelInactive lifecycle hook on Plc4xProtocolBase and Plc4xNettyWrapper; all drivers release resources on TCP disconnect (PR apache#2241) - fix(eip): NPE in decodeSingleReadResponse when PLC returns error status and getData() is null (PR apache#2471) - fix(umas): align pom version to 0.14.0.B-SNAPSHOT and fix RequestTransactionManager constructor call Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b39f3d7 commit 0955e9d

30 files changed

Lines changed: 463 additions & 245 deletions

File tree

plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,9 @@ private PlcResponseCode decodeResponseCode(short status) {
214214
return PlcResponseCode.NOT_FOUND;
215215
}
216216

217+
@Override
218+
public void channelInactive(ConversationContext<CIPEncapsulationPacket> context) {
219+
tm.shutdown();
220+
}
221+
217222
}

plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,4 +1985,9 @@ protected byte[] getNullByteTerminatedArray(String value) {
19851985
return nullTerminatedBytes;
19861986
}
19871987

1988+
@Override
1989+
public void channelInactive(ConversationContext<AmsTCPPacket> context) {
1990+
tm.shutdown();
1991+
}
1992+
19881993
}

plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,9 @@ private String toString(BacNetIpTag tag) {
288288
return tag.getDeviceIdentifier() + "/" + tag.getObjectType() + "/" + tag.getObjectInstance();
289289
}
290290

291+
@Override
292+
public void channelInactive(ConversationContext<BVLC> context) {
293+
// Nothing to do here ...
294+
}
295+
291296
}

plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/protocol/CBusProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,9 @@ public CompletableFuture<PlcReadResponse> read(PlcReadRequest readRequest) {
7878
protected void decode(ConversationContext<CBusCommand> context, CBusCommand msg) throws Exception {
7979
}
8080

81+
@Override
82+
public void channelInactive(ConversationContext<CBusCommand> context) {
83+
tm.shutdown();
84+
}
85+
8186
}

plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/CANDriverAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,9 @@ public void close(ConversationContext<C> context) {
113113
delegate.close(new ConversationContextWrapper<>(context, wireType, adapter, frameHandler, context.getAuthentication()));
114114
}
115115

116+
@Override
117+
public void channelInactive(ConversationContext<C> context) {
118+
delegate.channelInactive(new ConversationContextWrapper<>(context, wireType, adapter, frameHandler, context.getAuthentication()));
119+
}
120+
116121
}

plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,9 @@ public PlcConsumerRegistration register(Consumer<PlcSubscriptionEvent> consumer,
235235
public void unregister(PlcConsumerRegistration registration) {
236236
consumers.remove(registration);
237237
}
238+
239+
@Override
240+
public void channelInactive(ConversationContext<GenericFrame> context) {
241+
tm.shutdown();
242+
}
238243
}

plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,4 +480,9 @@ public void onDisconnect(ConversationContext<CANOpenFrame> context) {
480480
}
481481
}
482482

483+
@Override
484+
public void channelInactive(ConversationContext<CANOpenFrame> context) {
485+
tm.shutdown();
486+
}
487+
483488
}

plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/protocol/EipProtocolLogic.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,9 @@ private Map<String, PlcResponseItem<PlcValue>> decodeSingleReadResponse(CipServi
811811
CipReadResponse resp = (CipReadResponse) p;
812812
PlcResponseCode code = decodeResponseCode(resp.getStatus());
813813
PlcValue plcValue = null;
814-
CIPDataTypeCode type = resp.getData().getDataType();
815-
ByteBuf data = Unpooled.wrappedBuffer(resp.getData().getData());
816814
if (code == PlcResponseCode.OK) {
815+
CIPDataTypeCode type = resp.getData().getDataType();
816+
ByteBuf data = Unpooled.wrappedBuffer(resp.getData().getData());
817817
plcValue = parsePlcValue((EipTag) tag, data, type);
818818
}
819819
PlcResponseItem<PlcValue> result = new DefaultPlcResponseItem<>(code, plcValue);
@@ -1355,4 +1355,9 @@ private PlcResponseCode decodeResponseCode(int status) {
13551355
}
13561356
}
13571357

1358+
@Override
1359+
public void channelInactive(ConversationContext<EipPacket> context) {
1360+
tm.shutdown();
1361+
}
1362+
13581363
}

plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,9 @@ protected BitSet getDigitalValues(int byteBlock, List<Byte> data) {
320320
return BitSet.valueOf(bitSetData);
321321
}
322322

323+
@Override
324+
public void channelInactive(ConversationContext<FirmataMessage> context) {
325+
connected.set(false);
326+
}
327+
323328
}

plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/protocol/Iec608705104Protocol.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,9 @@ protected void publishEvent(LocalDateTime timeStamp, Iec608705104Tag tag, PlcVal
235235
}
236236
}
237237

238+
@Override
239+
public void channelInactive(ConversationContext<APDU> context) {
240+
tm.shutdown();
241+
}
242+
238243
}

0 commit comments

Comments
 (0)