You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Jean-Baptiste Onofré (Jira)" <ji...@apache.org> on 2020/10/09 03:29:00 UTC

[jira] [Assigned] (KARAF-5362) NPE creating session with a null "in" parameter from a SessionFactory

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

Jean-Baptiste Onofré reassigned KARAF-5362:
-------------------------------------------

    Assignee:     (was: Jean-Baptiste Onofré)

> NPE creating session with a null "in" parameter from a SessionFactory
> ---------------------------------------------------------------------
>
>                 Key: KARAF-5362
>                 URL: https://issues.apache.org/jira/browse/KARAF-5362
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>    Affects Versions: 4.1.2
>            Reporter: Emily Berk
>            Priority: Trivial
>
> The javadoc for {{SessionFactory#create(InputStream, PrintStream, PrintStream)}} says
> {code:java}
> @param in the input stream, can be <code>null</code> if the session is only used to execute a command using {@link Session#execute(CharSequence)}
> {code}
> When I try
> {code:java}
> package org.apache.karaf.shell.impl.console;
> import static org.easymock.EasyMock.createMock;
> import java.io.PrintStream;
> import java.io.UnsupportedEncodingException;
> import org.apache.felix.service.threadio.ThreadIO;
> import org.apache.karaf.shell.api.console.SessionFactory;
> import org.junit.Test;
> public class SessionFactoryImplTest {
>     
>     @Test
>     public void createWithNullInputStream() throws UnsupportedEncodingException {
>         final SessionFactory sessionFactory = new SessionFactoryImpl(createMock(ThreadIO.class));
>         sessionFactory.create(null, createMock(PrintStream.class), createMock(PrintStream.class));
>     }
> }
> {code}
> I get
> {code}
> java.lang.NullPointerException: "in" is null!
> 	at java.nio.channels.Channels.checkNotNull(Channels.java:67)
> 	at java.nio.channels.Channels.newChannel(Channels.java:347)
> 	at org.apache.felix.gogo.runtime.CommandSessionImpl.<init>(CommandSessionImpl.java:108)
> 	at org.apache.felix.gogo.runtime.CommandProcessorImpl.createSession(CommandProcessorImpl.java:82)
> 	at org.apache.felix.gogo.runtime.CommandProcessorImpl.createSession(CommandProcessorImpl.java:38)
> 	at org.apache.karaf.shell.impl.console.HeadlessSessionImpl.<init>(HeadlessSessionImpl.java:67)
> 	at org.apache.karaf.shell.impl.console.SessionFactoryImpl.create(SessionFactoryImpl.java:155)
> 	at org.apache.karaf.shell.impl.console.SessionFactoryImpl.create(SessionFactoryImpl.java:146)
> 	at org.apache.karaf.shell.impl.console.SessionFactoryImplTest.createWithNullInputStream(SessionFactoryImplTest.java:41)
> {code}
> A work-around is to pass a non-null {{InputStream}} that should never be called if the {{Session}} is only used to execute a command using {{Session#execute(CharSequence)}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)