dmux2313 opened a new issue, #13873:
URL: https://github.com/apache/ignite/issues/13873

     Ignite 2.18.0, on JDK 17+. Found in an application whose thin clients run 
in an  application server: a client there could not read the servers' node 
details, since the servers' binary configuration names a serializer class that 
lives in a web application on the servers only.
   
   ## Summary
   
   A server whose `BinaryConfiguration` has type configurations publishes them 
as the node attribute `org.apache.ignite.binary.config`, a map holding each 
type's serializer as a `java.lang.Class`. A thin client reads every server 
node's attributes when it reads the nodes  
`ClientCluster.forServers().nodes()`). When the client's JVM cannot load that 
serializer class, the read fails with `BinaryObjectException: Unexpected field 
type [... expected=Collection, actual=String]`: the attribute is read back 
shorter than it was written, and the client fails on the node's addresses that 
follow. Every later read of the nodes fails the same way.
   
   A server's serializer is server-side configuration. A client never needs to 
load it, and in an application server it usually cannot, since the class lives 
in a web application of the servers.
   
   ## Steps
   
   `repro.NodeAttributeClassRepro`, two cases, one server node each, the client 
in the same JVM:
   
   1. The type configuration's serializer is `repro.TemplateSerializer`, on the 
application class path.
   2. The serializer is the same class copied under another name, 
`repro.ServerOnlyTemplate`, defined by a class loader of  its own, which the 
server node gets as its class loader (`IgniteConfiguration.setClassLoader`), as 
an application server gives a node a web application's loader. The client,  
which reads through Ignite's own class loader, cannot load it.
   
   ## Actual
   
   ```
   1. a serializer class the client can load the server's attribute 
org.apache.ignite.binary.config: {globIdMapper=null, typeCfgs={true=[null, 
class repro.TemplateSerializer, false]}, compactFooter=true, 
globSerializer=null} OK: the client read 1 server node(s)
   2. a serializer class only the server's class loader has 
(repro.ServerOnlyTemplate) the server's attribute 
org.apache.ignite.binary.config: {globIdMapper=null, typeCfgs={true=[null, 
class repro.ServerOnlyTemplate, false]}, compactFooter=true, 
globSerializer=null} FAILED: the client could not read the server nodes: class 
org.apache.ignite.binary.BinaryObjectException: Unexpected field type 
[pos=17455, expected=Collection, actual=String]
   ```
   
   ## Expected
   
   The client reads the nodes in both cases. An attribute value the client 
cannot resolve is skipped or read as unknown, and the rest of the node's 
details are read.
   
   ## Where it happens
   
   - The attribute is built at the binary processor's start, each type 
configuration's id mapper and serializer as a `Class` 
(`internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java`, lines 
272–303). Its key is `c.getTypeName() != null`, a `Boolean`, so every type 
configuration lands under `true` and the last one wins.
   - The server writes a node's attributes, each value with 
`writeObjectDetached`, then the node's addresses as a collection 
(`internal/processors/platform/client/cluster/ClientClusterGroupGetNodesDetailsResponse.java`,
 `encode`;   `internal/processors/platform/utils/PlatformUtils.java`, lines 
1237–1252).
   - The client reads them back in the same order 
(`internal/client/thin/ClientClusterGroupImpl.java`, lines 430–452).  Not 
traced: where in the read of a `Class` the client loses its place instead of 
failing on the class.
   
   ## Workaround
   
   The attribute is not published with 
`-DIGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK=true` on the servers, which also 
skips the other configuration consistency checks at a node's join. Otherwise, a 
serializer class the clients can load.
   
   
     ## Reproducer
   
     A standalone Maven project, `ignite-core` only. Run with `mvn -q test` 
(JDK 17 or later); about 4 s, on loopback and in memory.
   
   
[g39-reproducer.zip](https://github.com/user-attachments/files/35284657/g39-reproducer.zip)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to