test_class.declarator: sessionManager
test_class.modifier: private
test_class.original_string: private SessionManager sessionManager;
test_class.type: SessionManager
test_class.var_name: sessionManager
test_class.declarator: expirationListener
test_class.modifier: private
test_class.original_string: private ExpirationListener expirationListener;
test_class.type: ExpirationListener
test_class.var_name: expirationListener
test_class.file: session-replacement/src/test/java/com/amadeus/session/repository/redis/TestExpirationListener.java
test_class.identifier: TestExpirationListener
test_case.body: @Test
    public void testOnPMessage() {
      String sessionId = "test-id";
      byte[] pattern = SafeEncoder.encode("");
      byte[] goodChannel = SafeEncoder.encode("_keyspace:test:expired");
      byte[] notExpireChannel = SafeEncoder.encode("_keyspace:test:expared");
      byte[] shortChannel = SafeEncoder.encode("expir");
      byte[] goodKey = SafeEncoder.encode("myprefix:key:test-id");
      byte[] shortKey = SafeEncoder.encode("myprefi");
      expirationListener.onPMessage(pattern, null, goodKey);
      verify(sessionManager, never()).deleteAsync(sessionId, true);
      expirationListener.onPMessage(pattern, goodChannel, null);
      verify(sessionManager, never()).deleteAsync(sessionId, true);
      expirationListener.onPMessage(pattern, notExpireChannel, goodKey);
      verify(sessionManager, never()).deleteAsync(sessionId, true);
      expirationListener.onPMessage(pattern, shortChannel, goodKey);
      verify(sessionManager, never()).deleteAsync(sessionId, true);
      expirationListener.onPMessage(pattern, goodChannel, shortKey);
      verify(sessionManager, never()).deleteAsync(sessionId, true);
      expirationListener.onPMessage(pattern, goodChannel, goodKey);
      verify(sessionManager).deleteAsync(sessionId, true);
    }
test_case.class_method_signature: TestExpirationListener.testOnPMessage()
test_case.full_signature: @Test public void testOnPMessage()
test_case.identifier: testOnPMessage
test_case.invocations: encode encode encode encode encode encode onPMessage deleteAsync verify never onPMessage deleteAsync verify never onPMessage deleteAsync verify never onPMessage deleteAsync verify never onPMessage deleteAsync verify never onPMessage deleteAsync verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testOnPMessage()
focal_class.declarator: logger = LoggerFactory.getLogger(ExpirationListener.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = LoggerFactory.getLogger(ExpirationListener.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: SUBSCRIPTION_PATTERN = "__keyevent@*__:expired"
focal_class.modifier: private static final
focal_class.original_string: private static final String SUBSCRIPTION_PATTERN = "__keyevent@*__:expired";
focal_class.type: String
focal_class.var_name: SUBSCRIPTION_PATTERN
focal_class.declarator: sessionManager
focal_class.modifier: private final
focal_class.original_string: private final SessionManager sessionManager;
focal_class.type: SessionManager
focal_class.var_name: sessionManager
focal_class.declarator: EXPIRED_SUFFIX = encode(":expired")
focal_class.modifier: private static final
focal_class.original_string: private static final byte[] EXPIRED_SUFFIX = encode(":expired");
focal_class.type: byte[]
focal_class.var_name: EXPIRED_SUFFIX
focal_class.declarator: keyPrefix
focal_class.modifier: private final
focal_class.original_string: private final byte[] keyPrefix;
focal_class.type: byte[]
focal_class.var_name: keyPrefix
focal_class.declarator: subsrcibed
focal_class.modifier: private
focal_class.original_string: private boolean subsrcibed;
focal_class.type: boolean
focal_class.var_name: subsrcibed
focal_class.declarator: linkedImplementation
focal_class.modifier: private
focal_class.original_string: private Object linkedImplementation;
focal_class.type: Object
focal_class.var_name: linkedImplementation
focal_class.file: session-replacement/src/main/java/com/amadeus/session/repository/redis/ExpirationListener.java
focal_class.identifier: ExpirationListener
focal_class.interfaces: implements RedisFacade.RedisPubSub
focal_class.class_method_signature: ExpirationListener.ExpirationListener(SessionManager sessionManager, String keyPrefix)
focal_class.full_signature:   ExpirationListener(SessionManager sessionManager, String keyPrefix)
focal_class.identifier: ExpirationListener
focal_class.parameters: (SessionManager sessionManager, String keyPrefix)
focal_class.signature:  ExpirationListener(SessionManager sessionManager, String keyPrefix)
focal_class.class_method_signature: ExpirationListener.onPMessage(byte[] pattern, byte[] channelBuf, byte[] message)
focal_class.full_signature: @Override public void onPMessage(byte[] pattern, byte[] channelBuf, byte[] message)
focal_class.identifier: onPMessage
focal_class.modifiers: @Override public
focal_class.parameters: (byte[] pattern, byte[] channelBuf, byte[] message)
focal_class.return: void
focal_class.signature: void onPMessage(byte[] pattern, byte[] channelBuf, byte[] message)
focal_class.class_method_signature: ExpirationListener.isExpiredChannel(byte[] channelBuf)
focal_class.full_signature: private boolean isExpiredChannel(byte[] channelBuf)
focal_class.identifier: isExpiredChannel
focal_class.modifiers: private
focal_class.parameters: (byte[] channelBuf)
focal_class.return: boolean
focal_class.signature: boolean isExpiredChannel(byte[] channelBuf)
focal_class.class_method_signature: ExpirationListener.isExpireKey(byte[] message)
focal_class.full_signature: private boolean isExpireKey(byte[] message)
focal_class.identifier: isExpireKey
focal_class.modifiers: private
focal_class.parameters: (byte[] message)
focal_class.return: boolean
focal_class.signature: boolean isExpireKey(byte[] message)
focal_class.class_method_signature: ExpirationListener.start(RedisFacade redis)
focal_class.full_signature:  void start(RedisFacade redis)
focal_class.identifier: start
focal_class.parameters: (RedisFacade redis)
focal_class.return: void
focal_class.signature: void start(RedisFacade redis)
focal_class.class_method_signature: ExpirationListener.close(RedisFacade redis)
focal_class.full_signature:  void close(RedisFacade redis)
focal_class.identifier: close
focal_class.parameters: (RedisFacade redis)
focal_class.return: void
focal_class.signature: void close(RedisFacade redis)
focal_class.class_method_signature: ExpirationListener.getLinked()
focal_class.full_signature: @Override public Object getLinked()
focal_class.identifier: getLinked
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Object
focal_class.signature: Object getLinked()
focal_class.class_method_signature: ExpirationListener.link(Object linkedImplementation)
focal_class.full_signature: @Override public void link(Object linkedImplementation)
focal_class.identifier: link
focal_class.modifiers: @Override public
focal_class.parameters: (Object linkedImplementation)
focal_class.return: void
focal_class.signature: void link(Object linkedImplementation)
focal_method.body: @Override
    public void onPMessage(byte[] pattern, byte[] channelBuf, byte[] message) {
      // Only accept messages expiration notification channel
      // and only those that match our key prefix.
      if (channelBuf == null || message == null) {
        return;
      }
      if (!isExpiredChannel(channelBuf)) {
        return;
      }
      if (!isExpireKey(message)) {
        return;
      }
  
      String body = encode(message);
      if (logger.isDebugEnabled()) {
        logger.debug("Got notification for channel: '{}', body: '{}'", encode(channelBuf), body);
      }
  
      String sessionId = RedisSessionRepository.extractSessionId(body);
      logger.info("Session expired event for sessionId: '{}'", sessionId);
  
      // We run session delete in another thread, otherwise we would block
      // listener.
      sessionManager.deleteAsync(sessionId, true);
    }
focal_method.class_method_signature: ExpirationListener.onPMessage(byte[] pattern, byte[] channelBuf, byte[] message)
focal_method.full_signature: @Override public void onPMessage(byte[] pattern, byte[] channelBuf, byte[] message)
focal_method.identifier: onPMessage
focal_method.invocations: isExpiredChannel isExpireKey encode isDebugEnabled debug encode extractSessionId info deleteAsync
focal_method.modifiers: @Override public
focal_method.parameters: (byte[] pattern, byte[] channelBuf, byte[] message)
focal_method.return: void
focal_method.signature: void onPMessage(byte[] pattern, byte[] channelBuf, byte[] message)