mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emmanuel Lecharny (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (FTPSERVER-476) NullPointerException when SessionFilter.accept() returns false
Date Wed, 02 Nov 2016 21:33:58 GMT

     [ https://issues.apache.org/jira/browse/FTPSERVER-476?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Emmanuel Lecharny resolved FTPSERVER-476.
-----------------------------------------
    Resolution: Fixed

Re-fixed :-)

And don't worry, I could also have thought about the potential NPE that your second fix corrected
!

> NullPointerException when SessionFilter.accept() returns false
> --------------------------------------------------------------
>
>                 Key: FTPSERVER-476
>                 URL: https://issues.apache.org/jira/browse/FTPSERVER-476
>             Project: FtpServer
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.1.0
>            Reporter: Manuel Dominguez Sarmiento
>             Fix For: 1.1.1
>
>
> We have the following code for setting up listeners before starting the FTP server:
> 		ListenerFactory listenerFactory = new ListenerFactory();
> 		listenerFactory.setPort(controlPort);
> 		listenerFactory.setDataConnectionConfiguration(dataConnectionConfig);
> 		listenerFactory.setSessionFilter(new SessionFilter() {
> 			@Override
> 			public boolean accept(IoSession ioSession) {
> 				InetAddress address = ((InetSocketAddress) ioSession.getRemoteAddress()).getAddress();
> 				boolean accept = !enableIpSecurity || allowedIpAddresses.contains(address.getHostAddress());
> 				if (accept) {
> 					log.info("Login attempt from " + address.getHostAddress() + " successful");
> 				} else {
> 					log.warn("Login attempt from " + address.getHostAddress() + " failed");
> 				}
> 				return accept;
> 			}
> 		});
> 		Listener listener = listenerFactory.createListener();
> When SessionFilter.accept() returns false everything works fine from the user standpoint,
however we get the following stack trace in the logs:
> [WARN ] 2016-11-02 10:35:39 [DefaultFtpHandler-pool-29-thread-1] - Data connection threw
an exception on disconnect
> java.lang.NullPointerException
>         at org.apache.ftpserver.impl.IODataConnectionFactory.<init>(IODataConnectionFactory.java:80)
>         at org.apache.ftpserver.impl.FtpIoSession.getDataConnection(FtpIoSession.java:554)
>         at org.apache.ftpserver.impl.DefaultFtpHandler.sessionClosed(DefaultFtpHandler.java:106)
>         at org.apache.ftpserver.listener.nio.FtpHandlerAdapter.sessionClosed(FtpHandlerAdapter.java:72)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionClosed(DefaultIoFilterChain.java:797)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:504)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:48)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:927)
>         at org.apache.mina.filter.logging.LoggingFilter.sessionClosed(LoggingFilter.java:238)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:504)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:48)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:927)
>         at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:109)
>         at org.apache.mina.filter.logging.MdcInjectionFilter.filter(MdcInjectionFilter.java:135)
>         at org.apache.mina.filter.util.CommonEventFilter.sessionClosed(CommonEventFilter.java:55)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:504)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:48)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:927)
>         at org.apache.mina.filter.codec.ProtocolCodecFilter.sessionClosed(ProtocolCodecFilter.java:360)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionClosed(DefaultIoFilterChain.java:504)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$900(DefaultIoFilterChain.java:48)
>         at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionClosed(DefaultIoFilterChain.java:927)
>         at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:109)
>         at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
>         at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:770)
>         at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:762)
>         at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:704)
>         at java.lang.Thread.run(Thread.java:745)
> What seems to be happening is that the constructor for IODataConnectionFactory is expecting
the session parameter to be non-null however since SessionFilter.accept() returns false, then
this is not the case:
>     if (session.getListener().getDataConnectionConfiguration().isImplicitSsl()) {
>       secure = true;
>     }
> Thus we get a NullPointerException. This snippet should probably be changed to:
>     if (session != null && session.getListener().getDataConnectionConfiguration().isImplicitSsl())
{
>       secure = true;
>     }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message