Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HazelcastInstance.getCache return type to allow proxying #8372

Closed

Conversation

vbekiaris
Copy link
Collaborator

Avoid ClassNotFoundException when JCache is not in the classpath and HazelcastInstance is proxied (eg. when mocking with Mockito, instantiating as Spring bean).
In a separate commit, added a convenience method in CacheUtil that returns the distributed object name for the given cache, which can be used to obtain an ICache reference from HazelcastInstance.getDistributedObject.
Fixes #8352

@devOpsHazelcast
Copy link
Collaborator

Test FAILed.

@vbekiaris vbekiaris force-pushed the fixes/master/hzinstance-getCache branch from fcf58da to 7d69d39 Compare June 14, 2016 12:37
@devOpsHazelcast
Copy link
Collaborator

Test PASSed.

@serkan-ozal
Copy link
Contributor

Regarding to existence of the ICache in the generated byte code:

this is the output of javap -verbose HazelcastInstance.class:

public abstract <C extends java.io.Closeable & com.hazelcast.cache.ICache> C getCache(java.lang.String);
    descriptor: (Ljava/lang/String;)Ljava/io/Closeable;
    flags: ACC_PUBLIC, ACC_ABSTRACT
    Signature: #64                          // <C::Ljava/io/Closeable;:Lcom/hazelcast/cache/ICache;>(Ljava/lang/String;)TC;
Method m = HazelcastInstance.class.getMethod("getCache", String.class);
Type[] returnTypes = ((TypeVariableImpl) m.getGenericReturnType()).getBounds();
for (Type returnType : returnTypes) {
    System.out.println(returnType);
}

prints

interface java.io.Closeable
interface com.hazelcast.cache.ICache

@vbekiaris vbekiaris closed this Jun 17, 2016
@mmedenjak mmedenjak added the Source: Internal PR or issue was opened by an employee label Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Internal PR or issue was opened by an employee
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NoClassDefFoundError: javax/cache/Cache when mocking HazelcastInstance with 3.7
4 participants