Possible Bug with Collections and POF
630208Jul 24 2009 — edited Jul 27 2009Hi Guys,
Here is a possible Bug with Collections and POF, how do I go about reporting it as a bug?
My usecase:
Insert data(key=List, value=String) by a Java peer to the Grid and access the data by a C# client via TCP Proxy server.
Bug:
When accessing values by their key in C# returns null if the key is a List.
Here is what I am doing:
JAVA Side:
1. Start Proxy server with comand line parameters
-Dtangosol.coherence.cluster=test -Dtangosol.coherence.clusterport=56566
-Dtangosol.coherence.cacheconfig=C:\config\proxyCacheConfig.xml
proxyCacheConfig.xml:---
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>*</cache-name>
<scheme-name>data</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<distributed-scheme>
<scheme-name>data</scheme-name>
<lease-granularity>member</lease-granularity>
<backing-map-scheme>
<local-scheme/>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
<proxy-scheme>
<service-name>ExtendTcpProxyService</service-name>
<thread-count>5</thread-count>
<acceptor-config>
<tcp-acceptor>
<local-address>
<address>localhost</address>
<port>9876</port>
</local-address>
</tcp-acceptor>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>file:config/proxyServer/java-pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
</acceptor-config>
<proxy-config>
<cache-service-proxy>
<lock-enabled>true</lock-enabled>
</cache-service-proxy>
</proxy-config>
<autostart>true</autostart>
</proxy-scheme>
</caching-schemes>
</cache-config>
java-pof-config.xml:--
<?xml version="1.0"?>
<pof-config>
<user-type-list>
<include>coherence-pof-config.xml</include>
</user-type-list>
</pof-config>
2. Insert data by a Java Peer
public class TestCoherence{
public static void main (String[] args) throws Exception {
System.setProperty("tangosol.coherence.cluster", "test");
System.setProperty("tangosol.coherence.clusterport", "56566");
NamedCache cache = CacheFactory.getCache("mycache");
List key = new ArrayList();
key.add(1);
key.add(2);
key.add(3);
cache.put(key, " ValueIsPresent");
}
}
C# Side:
3. Access data by a C# client.
coherence-cache-config.xml on C# client
<?xml version="1.0"?>
<cache-config xmlns="http://schemas.tangosol.com/cache">
<caching-scheme-mapping>
<cache-mapping>
<cache-name>*</cache-name>
<scheme-name>extend-direct</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<remote-cache-scheme>
<scheme-name>extend-direct</scheme-name>
<service-name>ExtendTcpCacheService</service-name>
<initiator-config>
<tcp-initiator>
<remote-addresses>
<socket-address>
<address>localhost</address>
<port>9876</port>
</socket-address>
</remote-addresses>
</tcp-initiator>
<outgoing-message-handler>
<request-timeout>30s</request-timeout>
</outgoing-message-handler>
</initiator-config>
</remote-cache-scheme>
</caching-schemes>
</cache-config>
class GetDataFromCSharp
{
static void Main()
{
INamedCache namedCache = CacheFactory.GetCache("mycache");
ICacheEntry[] entries = namedCache.GetEntries(AlwaysFilter.Instance);
foreach(ICacheEntry entry in entries)
{
Console.Out.WriteLine("Key returned by GetEntries() : " + convertToString((Object[])entry.Key));
Console.Out.WriteLine("Value returned by GetEntries() : " + entry.Value.ToString());
Object valueByEntry = namedCache[entry.Key];
if (valueByEntry == null)
{
valueByEntry = "NULL";
}
Console.Out.WriteLine("Value retrieved using key returned by GetEntries() :" + valueByEntry);
}
Object[] keys = namedCache.GetKeys(AlwaysFilter.Instance);
foreach(Object key in keys)
{
Object valueByKey= namedCache[key];
if (valueByKey == null)
{
valueByKey = "NULL";
}
Console.Out.WriteLine("Value retrieved using key returned by GetKeys() :" + valueByKey);
}
Object[] values = namedCache.GetValues(AlwaysFilter.Instance);
foreach (Object value in values)
{
Console.Out.WriteLine("Value returned by GetValues():" + value.ToString());
}
}
private static String convertToString(object[] key)
{
String returnValue = "";
foreach(Object entry in key)
{
returnValue += entry.ToString();
}
return returnValue;
}
}
}
Output:
Key returned by GetEntries() : 123
Value returned by GetEntries() : ValueIsPresent
Value retrieved using key returned by GetEntries() : NULL
Value retrieved using key returned by GetKeys() : NULL
Value returned by GetValues() : ValueIsPresent
Any ideas as to why it returns null when key is a List are very much appreciated. Infact, same behavior can be reproduced with other collection types i.e Map, Set.
Kindest Regards
K