I am using type variables in my abstract parent service class where I have some service methods. I am using @HystrixCommand annotation to use some fallback method.
Here is my sample code
@Service
public abstract class MyAbstractParentClass<T extends IModel<T>,S extends Serializable> implements IService<T, S>, InitializingBean{
private MyRepo<T, S > repo;
@Override
@HystrixCommand(fallbackMethod="handleError", groupKey="MyClass", commandKey="findUserTest")
public T findUserTest(S userId){
String str = null;
System.out.println(str.length());// intentional nullpointer exception
T user = repo.findOne(userId);
return user;
}
public T handleError(S userId){
T user = repo.findOne(userId);
return user;
}
public abstract MyRepo<T, S> getRepository();
@Override
public void afterPropertiesSet() throws Exception {
repo = getRepository();
}
}
But unfortunately after using the annotation my api is not working it is giving the below java heap space error.
{
"timestamp": 1500581418921,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.OutOfMemoryError",
"message": "Java heap space",
"path": "/rest/api/path"
}
If I do not use any type variables it is working fine in the parent class
@HystrixCommand(fallbackMethod="handleError", groupKey="MyClass", commandKey="findUserTest")
public String findUserTest(String userId){
String str = null;
System.out.println(str.length());
return userId;
}
public String handleError(String userId){
return "Error Handled";
}
If I use this annotation in any of my child classes service methods, fallback mechanism is working fine.
Any help will be appreciated