You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "nabarun (JIRA)" <ji...@apache.org> on 2018/10/03 21:38:23 UTC
[jira] [Closed] (GEODE-5450) Creating a JNDI binding w/o a username
or password leads to NullPointerException
[ https://issues.apache.org/jira/browse/GEODE-5450?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
nabarun closed GEODE-5450.
--------------------------
> Creating a JNDI binding w/o a username or password leads to NullPointerException
> --------------------------------------------------------------------------------
>
> Key: GEODE-5450
> URL: https://issues.apache.org/jira/browse/GEODE-5450
> Project: Geode
> Issue Type: Bug
> Components: gfsh
> Reporter: Bradford D. Boyle
> Assignee: Benjamin P Ross
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.7.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> If a user creates a JNDI binding through gfsh and they omit either the username or password, then they will get a `NullPointerException` when they try to get a JDBC connection.
>
> Here is a stack trace:
> {code}
> java.lang.NullPointerException
> at java.util.Hashtable.put(Hashtable.java:460)
> at org.apache.geode.internal.datasource.GemFireBasicDataSource.getConnection(GemFireBasicDataSource.java:94)
> at io.pivotal.gemfire.PostgresVersionFunction.execute(PostgresVersionFunction.java:33)
> at org.apache.geode.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:333)
> at org.apache.geode.internal.cache.execute.AbstractExecution$2.run(AbstractExecution.java:302)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at org.apache.geode.distributed.internal.ClusterDistributionManager.runUntilShutdown(ClusterDistributionManager.java:1121)
> at org.apache.geode.distributed.internal.ClusterDistributionManager.access$000(ClusterDistributionManager.java:109)
> at org.apache.geode.distributed.internal.ClusterDistributionManager$9$1.run(ClusterDistributionManager.java:990)
> at java.lang.Thread.run(Thread.java:748)
> {code}
> You can reproduce this with the following function:
> {code:language=java}
> public class PostgresVersionFunction implements Function {
> @Override
> public void execute(FunctionContext context) {
> String[] arguments = (String[]) context.getArguments();
> String dataSourceName = arguments[0];
> LogManager.getLogger().info("[datasource=" + context.getArguments()+"]");
> Context ctx = JNDIInvoker.getJNDIContext();
> DataSource dataSource;
> try {
> dataSource = (DataSource) ctx.lookup("java:/" + dataSourceName);
> } catch (Exception e) {
> // TODO exception handling.
> LogManager.getLogger().error(e.getMessage(), e);
> context.getResultSender().lastResult(e);
> return;
> }
> try (Connection connection = dataSource.getConnection();
> Statement statement = connection.createStatement()
> ) {
> ResultSet resultSet = statement.executeQuery("SELECT VERSION();");
> resultSet.next();
> context.getResultSender().lastResult(resultSet.getString(1));
> } catch (SQLException e) {
> context.getResultSender().lastResult(e);
> }
> }
> }
> {code}
> and the following gfsh commands:
> {code}
> start locator --name=locator --include-system-classpath
> start server --name=server1 --include-system-classpath
> deploy --jar=/root/gemfire-greenplum/simple-function.jar
> create jndi-binding --name=datasource --type=SIMPLE --jdbc-driver-class="org.postgresql.Driver" --connection-url="jdbc:postgresql://localhost:5432/gpadmin"
> execute function --id=io.pivotal.gemfire.PostgresVersionFunction --arguments=datasource
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)