[
https://issues.apache.org/jira/browse/DIRMINA-684?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Emmanuel Lecharny updated DIRMINA-684:
--------------------------------------
Fix Version/s: (was: 2.0.0-RC2)
2.0.0
> NullPointerException when opening socket to localhost
> -----------------------------------------------------
>
> Key: DIRMINA-684
> URL: https://issues.apache.org/jira/browse/DIRMINA-684
> Project: MINA
> Issue Type: Bug
> Affects Versions: 2.0.0-M5
> Environment: Linux
> Reporter: David Rosenstrauch
> Priority: Minor
> Fix For: 2.0.0
>
>
> I have a MINA-based server I've written that's up and running and works fine.
> I recently added a new bit of functionality to it, however, and it's now
> throwing NullPointerExceptions intermittently.
> The server uses a text-based protocol (using TextLineCodecFactory). I've
> added the capability to give the server a command line parm which is the name
> of a text file, containing startup commands that the server should execute
> after it starts up. I'm doing this by having the server open a java socket
> to the server's port on localhost, read the text file and write (and flush)
> each command out to the socket.
> This is generally working, and the server is receiving and processing each
> command (not always in the order sent, but I'm guessing that's an outgrowth
> of my using a thread pool, and that's not a problem anyway). But from time to
> time, the server is spitting out this error:
> SEVERE: EXCEPTION :
> org.apache.mina.filter.codec.ProtocolEncoderException:
> java.lang.NullPointerException
> at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:312)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:506)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1400(DefaultIoFilterChain.java:48)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:814)
> at
> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:65)
> at org.apache.mina.core.session.IoEvent.run(IoEvent.java:64)
> at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:552)
> at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:544)
> at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:488)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException
> at
> org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:297)
> ... 9 more
> Or sometimes another similar error as well:
> SEVERE: Error occurred during message handling
> org.apache.mina.filter.codec.ProtocolDecoderException:
> java.lang.NullPointerException (Hexdump: 68 65 6C 70 0A 73 74 61 74 73 0A 71
> 75 65 72 79 20 31 32 33 34 0A)
> at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:234)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:48)
> at
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:802)
> at
> org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:59)
> at org.apache.mina.core.session.IoEvent.run(IoEvent.java:64)
> at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:552)
> at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:544)
> at
> org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:488)
> at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException
> at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:224)
> ... 9 more
> Noteworthy aspects of my configuration:
> * using the M4 release of MINA
> * I'm not pausing between sending commands; i.e., I'm write and flushing them
> down the socket as quickly as Java can send them
> * I'm using both a read and a write thread pool
> * building my filter chain as follows:
> protocolAcceptor = new NioSocketAcceptor();
> protocolAcceptor.setDefaultLocalAddress(new
> InetSocketAddress(protocolPort));
> protocolAcceptor.setReuseAddress(true);
> DefaultIoFilterChainBuilder filterChainBuilder =
> protocolAcceptor.getFilterChain();
> filterChainBuilder.addLast("logger", new
> LoggingFilter(ProfileCacheServer.class));
> readerThreadPool = new OrderedThreadPoolExecutor();
> filterChainBuilder.addLast("readExecutor", new
> ExecutorFilter(readerThreadPool, IoEventType.MESSAGE_RECEIVED));
> filterChainBuilder.addLast("codec", new ProtocolCodecFilter(new
> TextLineCodecFactory(ParseConstants.UTF8_CHARSET)));
> writerThreadPool = new OrderedThreadPoolExecutor();
> filterChainBuilder.addLast("writeExecutor", new
> ExecutorFilter(writerThreadPool, IoEventType.WRITE));
> protocolAcceptor.setHandler(protocolHandler);
> I actually did find a way to "fix" this problem but someone on the mailing
> list suggested that MINA shouldn't be throwing NPE's regardless. Fix is as
> follows: I was originally just dropping the connection on the client side
> when I was finished. But after changing my code to issue a proper "close
> connection" command to the server before disconnecting, it looks like the
> NPE's go away.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.