mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tuan (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (FTPSERVER-476) NullPointerException when SessionFilter.accept() returns false
Date Tue, 09 Oct 2018 04:06:00 GMT

    [ https://issues.apache.org/jira/browse/FTPSERVER-476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16642769#comment-16642769
] 

Tuan edited comment on FTPSERVER-476 at 10/9/18 4:05 AM:
---------------------------------------------------------

The issue came from MinaSessionFilter. The session was closed immediately when filter return
false.

When we have SessionFilter, At NioListener will add MinaSessionFilter to the last filterchain
and when we do not accept (SessionFilter return false) the error occured.

I'm using version 1.1.0 and i did not know how can we fixed it. :)


was (Author: tuannn0107):
The issue came from MinaSessionFilter. The session was closed immediately when filter return
false.

When we have SessionFilter, At NioListener will add MinaSessionFilter to the last filterchain
and when we did not accept (SessionFilter return false) the error occur.

I'm using version 1.1.0 and i did not know how can we fixed it. :)

> 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
>            Priority: Major
>             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
(v7.6.3#76005)

Mime
View raw message