karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Emily Berk (JIRA)" <j...@apache.org>
Subject [jira] [Created] (KARAF-5362) NPE Creating Session with a null "in" parameter from a SessionFactory
Date Tue, 12 Sep 2017 00:04:00 GMT
Emily Berk created KARAF-5362:
---------------------------------

             Summary: 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-shell
    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
(v6.4.14#64029)

Mime
View raw message