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

A NullPointerException is thrown when listen the key expire event [DATAREDIS-572] #1147

Closed
spring-projects-issues opened this issue Nov 15, 2016 · 1 comment
Assignees
Labels
status: duplicate A duplicate of another issue type: bug A general bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Nov 15, 2016

Yang Lifan opened DATAREDIS-572 and commented

When I use KeyExpirationEventMessageListener, I found the expired key must be the pattern like "keyspace:key". Otherwise, if the expired key without the keyspace part, just like "key", KeyExpirationEventMessageListener will throw a NullPointerException:

org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.NullPointerException
	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:38) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:212) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.connection.jedis.JedisConnection.sRem(JedisConnection.java:2071) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
	at org.springframework.data.redis.core.CloseSuppressingInvocationHandler.invoke(CloseSuppressingInvocationHandler.java:57) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at com.sun.proxy.$Proxy64.sRem(Unknown Source) ~[na:na]
	at org.springframework.data.redis.core.RedisKeyValueAdapter$8.doInRedis(RedisKeyValueAdapter.java:538) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.core.RedisKeyValueAdapter$8.doInRedis(RedisKeyValueAdapter.java:530) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:204) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:166) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:154) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.core.RedisKeyValueAdapter.onApplicationEvent(RedisKeyValueAdapter.java:530) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.core.RedisKeyValueAdapter.onApplicationEvent(RedisKeyValueAdapter.java:93) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
	at org.springframework.data.redis.listener.KeyExpirationEventMessageListener.publishEvent(KeyExpirationEventMessageListener.java:72) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.listener.KeyExpirationEventMessageListener.doHandleMessage(KeyExpirationEventMessageListener.java:61) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.listener.KeyspaceEventMessageListener.onMessage(KeyspaceEventMessageListener.java:62) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.listener.RedisMessageListenerContainer.executeListener(RedisMessageListenerContainer.java:249) [spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.listener.RedisMessageListenerContainer.processMessage(RedisMessageListenerContainer.java:239) [spring-data-redis-1.7.5.RELEASE.jar:na]
	at org.springframework.data.redis.listener.RedisMessageListenerContainer$1.run(RedisMessageListenerContainer.java:967) [spring-data-redis-1.7.5.RELEASE.jar:na]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]
Caused by: java.lang.NullPointerException: null
	at redis.clients.jedis.Protocol.sendCommand(Protocol.java:97) ~[jedis-2.8.2.jar:na]
	at redis.clients.jedis.Protocol.sendCommand(Protocol.java:82) ~[jedis-2.8.2.jar:na]
	at redis.clients.jedis.Connection.sendCommand(Connection.java:101) ~[jedis-2.8.2.jar:na]
	at redis.clients.jedis.BinaryClient.srem(BinaryClient.java:337) ~[jedis-2.8.2.jar:na]
	at redis.clients.jedis.BinaryJedis.srem(BinaryJedis.java:1237) ~[jedis-2.8.2.jar:na]
	at org.springframework.data.redis.connection.jedis.JedisConnection.sRem(JedisConnection.java:2069) ~[spring-data-redis-1.7.5.RELEASE.jar:na]
	... 24 common frames omitted

From the source code, Spring Redis will try to remove a value from a set, the key of the set is the keyspace:

connection.sRem(toBytes(expiredEvent.getKeyspace()), expiredEvent.getId());

But I only found an empty set by the keyspace:

scard keysapce
(integer) 0

And when I use native Redis command to pub/sub key expired event, the key wasn't necessary with the pattern "keyspace:key".

So I do not think the keyspace is necessary when use Spring Redis to subscribe the key expired event.


Affects: 1.7.5 (Hopper SR5)

Issue Links:

  • DATAREDIS-744 Secondary indexes not removed if id contains colon
    ("is superseded by")
@spring-projects-issues
Copy link
Author

spring-projects-issues commented Feb 13, 2020

Mark Paluch commented

Fixed with DATAREDIS-744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants