Buggy code:
public class SingleConnectionFactory implements ConnectionFactory , ExceptionListener , QueueConnectionFactory , TopicConnectionFactory , DisposableBean , InitializingBean { protected final Log logger = LogFactory . getLog ( getClass ( ) ) ; private ConnectionFactory targetConnectionFactory ; private String clientId ; private ExceptionListener exceptionListener ; private boolean reconnectOnException = false ; private Connection target ; private Connection connection ; private Boolean pubSubMode ; private boolean started = false ; private final Object connectionMonitor = new Object ( ) ; public SingleConnectionFactory ( ) { } public SingleConnectionFactory ( Connection target ) { } public SingleConnectionFactory ( ConnectionFactory targetConnectionFactory ) { } public void setTargetConnectionFactory ( ConnectionFactory targetConnectionFactory ) { } public ConnectionFactory getTargetConnectionFactory ( ) { } public void setClientId ( String clientId ) { } protected String getClientId ( ) { } public void setExceptionListener ( ExceptionListener exceptionListener ) { } protected ExceptionListener getExceptionListener ( ) { } public void setReconnectOnException ( boolean reconnectOnException ) { } protected boolean isReconnectOnException ( ) { } public void afterPropertiesSet ( ) { } public Connection createConnection ( ) throws JMSException { } public Connection createConnection ( String username , String password ) throws JMSException { } public QueueConnection createQueueConnection ( ) throws JMSException { } public QueueConnection createQueueConnection ( String username , String password ) throws JMSException { } public TopicConnection createTopicConnection ( ) throws JMSException { } public TopicConnection createTopicConnection ( String username , String password ) throws JMSException { } public void initConnection ( ) throws JMSException { } public void onException ( JMSException ex ) { } public void destroy ( ) { } public void resetConnection ( ) { } protected Connection doCreateConnection ( ) throws JMSException { } protected void prepareConnection ( Connection con ) throws JMSException { } protected Session getSession ( Connection con , Integer mode ) throws JMSException { } protected Session createSession ( Connection con , Integer mode ) throws JMSException { } protected void closeConnection ( Connection con ) { } protected Connection getSharedConnectionProxy ( Connection target ) { } private class SharedConnectionInvocationHandler implements InvocationHandler { private final Connection target ; public SharedConnectionInvocationHandler ( Connection target ) { } public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable { if ( method . getName ( ) . equals ( "equals" ) ) { <START_BUG> return proxy == ( args [ 0 ] ) ? Boolean . TRUE : Boolean . FALSE ; <END_BUG> } else if ( method . getName ( ) . equals ( "hashCode" ) ) { return System . identityHashCode ( proxy ) ; } else if ( method . getName ( ) . equals ( "toString" ) ) { return "Shared<seq2seq4repair_space>JMS<seq2seq4repair_space>Connection:<seq2seq4repair_space>" + ( this . target ) ; } else if ( method . getName ( ) . equals ( "setClientID" ) ) { String currentClientId = this . target . getClientID ( ) ; if ( ( currentClientId != null ) && ( currentClientId . equals ( args [ 0 ] ) ) ) { return null ; } else { throw new IllegalStateException ( ( "setClientID<seq2seq4repair_space>call<seq2seq4repair_space>not<seq2seq4repair_space>supported<seq2seq4repair_space>on<seq2seq4repair_space>proxy<seq2seq4repair_space>for<seq2seq4repair_space>shared<seq2seq4repair_space>Connection.<seq2seq4repair_space>" + "Set<seq2seq4repair_space>the<seq2seq4repair_space>'clientId'<seq2seq4repair_space>property<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>SingleConnectionFactory<seq2seq4repair_space>instead." ) ) ; } } else if ( method . getName ( ) . equals ( "setExceptionListener" ) ) { ExceptionListener currentExceptionListener = this . target . getExceptionListener ( ) ; if ( ( currentExceptionListener instanceof SingleConnectionFactory . InternalChainedExceptionListener ) && ( ( args [ 0 ] ) != null ) ) { ( ( SingleConnectionFactory . InternalChainedExceptionListener ) ( currentExceptionListener ) ) . addDelegate ( ( ( ExceptionListener ) ( args [ 0 ] ) ) ) ; return null ; } else { throw new IllegalStateException ( ( "setExceptionListener<seq2seq4repair_space>call<seq2seq4repair_space>not<seq2seq4repair_space>supported<seq2seq4repair_space>on<seq2seq4repair_space>proxy<seq2seq4repair_space>for<seq2seq4repair_space>shared<seq2seq4repair_space>Connection.<seq2seq4repair_space>" + ( ( "Set<seq2seq4repair_space>the<seq2seq4repair_space>'exceptionListener'<seq2seq4repair_space>property<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>SingleConnectionFactory<seq2seq4repair_space>instead.<seq2seq4repair_space>" + "Alternatively,<seq2seq4repair_space>activate<seq2seq4repair_space>SingleConnectionFactory's<seq2seq4repair_space>'reconnectOnException'<seq2seq4repair_space>feature,<seq2seq4repair_space>" ) + "which<seq2seq4repair_space>will<seq2seq4repair_space>allow<seq2seq4repair_space>for<seq2seq4repair_space>registering<seq2seq4repair_space>further<seq2seq4repair_space>ExceptionListeners<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>recovery<seq2seq4repair_space>chain." ) ) ) ; } } else if ( method . getName ( ) . equals ( "start" ) ) { this . target . start ( ) ; synchronized ( connectionMonitor ) { started = true ; } return null ; } else if ( method . getName ( ) . equals ( "stop" ) ) { return null ; } else if ( method . getName ( ) . equals ( "close" ) ) { return null ; } else if ( ( ( method . getName ( ) . equals ( "createSession" ) ) || ( method . getName ( ) . equals ( "createQueueSession" ) ) ) || ( method . getName ( ) . equals ( "createTopicSession" ) ) ) { boolean transacted = ( ( Boolean ) ( args [ 0 ] ) ) ; Integer ackMode = ( ( Integer ) ( args [ 1 ] ) ) ; Integer mode = ( transacted ) ? Session . SESSION_TRANSACTED : ackMode ; Session session = getSession ( this . target , mode ) ; if ( session != null ) { if ( ! ( method . getReturnType ( ) . isInstance ( session ) ) ) { String msg = "JMS<seq2seq4repair_space>Session<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>implement<seq2seq4repair_space>specific<seq2seq4repair_space>domain:<seq2seq4repair_space>" + session ; try { session . close ( ) ; } catch ( Throwable ex ) { logger . trace ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>close<seq2seq4repair_space>newly<seq2seq4repair_space>obtained<seq2seq4repair_space>JMS<seq2seq4repair_space>Session" , ex ) ; } throw new IllegalStateException ( msg ) ; } return session ; } } try { Object retVal = method . invoke ( this . target , args ) ; if ( ( method . getName ( ) . equals ( "getExceptionListener" ) ) && ( retVal instanceof SingleConnectionFactory . InternalChainedExceptionListener ) ) { SingleConnectionFactory . InternalChainedExceptionListener listener = ( ( SingleConnectionFactory . InternalChainedExceptionListener ) ( retVal ) ) ; return listener . getUserListener ( ) ; } else { return retVal ; } } catch ( InvocationTargetException ex ) { throw ex . getTargetException ( ) ; } } } private static class InternalChainedExceptionListener extends ChainedExceptionListener { private ExceptionListener userListener ; public InternalChainedExceptionListener ( ExceptionListener internalListener , ExceptionListener userListener ) { } public ExceptionListener getUserListener ( ) { } } }

Fix:
return proxy == ( args [ 0 ] ) ;