Fix for a possible NPE - Mailing list pgsql-jdbc

From Pierre Queinnec
Subject Fix for a possible NPE
Date
Msg-id 4BA52705.7070406@zenika.com
Whole thread Raw
Responses Re: Fix for a possible NPE  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
Hi guys,

Here's a little patch [1] that fixes a possible NPE. While I'm at it, I
also attached three other patches that I had, one to suppress a unused
field [2], another one to suppress a double null-check [3], and a small
typo correction [4].

[1] SimpleParameterList_NPE.diff
[2] CopyOperationImpl_unused_field.diff
[3] QueryExecutorImpl_double_null_check.diff
[4] Fastpath_typo.diff

Cheers,
--
Pierre Queinnec
CTO - Zenika
http://www.zenika.com

Index: org/postgresql/core/v3/SimpleParameterList.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/core/v3/SimpleParameterList.java,v
retrieving revision 1.18
diff -c -r1.18 SimpleParameterList.java
*** org/postgresql/core/v3/SimpleParameterList.java    4 Feb 2010 00:48:47 -0000    1.18
--- org/postgresql/core/v3/SimpleParameterList.java    20 Mar 2010 19:39:04 -0000
***************
*** 155,161 ****

              p.append('\'');
              try {
!                 p = Utils.appendEscapedLiteral(p, param, protoConnection.getStandardConformingStrings());
              } catch (SQLException sqle) {
                  // This should only happen if we have an embedded null
                  // and there's not much we can do if we do hit one.
--- 155,161 ----

              p.append('\'');
              try {
!                 p = Utils.appendEscapedLiteral(p, param, standardConformingStrings);
              } catch (SQLException sqle) {
                  // This should only happen if we have an embedded null
                  // and there's not much we can do if we do hit one.
Index: org/postgresql/core/v3/CopyOperationImpl.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/core/v3/CopyOperationImpl.java,v
retrieving revision 1.1
diff -c -r1.1 CopyOperationImpl.java
*** org/postgresql/core/v3/CopyOperationImpl.java    1 Jul 2009 05:00:40 -0000    1.1
--- org/postgresql/core/v3/CopyOperationImpl.java    20 Mar 2010 19:37:52 -0000
***************
*** 17,23 ****
  import org.postgresql.util.PSQLState;

  public class CopyOperationImpl implements CopyOperation {
-     String sql;
      QueryExecutorImpl queryExecutor;
      int rowFormat;
      int[] fieldFormats;
--- 17,22 ----
Index: org/postgresql/core/v3/QueryExecutorImpl.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/core/v3/QueryExecutorImpl.java,v
retrieving revision 1.47
diff -c -r1.47 QueryExecutorImpl.java
*** org/postgresql/core/v3/QueryExecutorImpl.java    7 Dec 2009 22:03:06 -0000    1.47
--- org/postgresql/core/v3/QueryExecutorImpl.java    20 Mar 2010 19:38:33 -0000
***************
*** 980,986 ****
                      error = new PSQLException(GT.tr("Got CopyData without an active copy operation"),
PSQLState.OBJECT_NOT_IN_STATE);
                  } else if (!(op instanceof CopyOutImpl)) {
                      error = new PSQLException(GT.tr("Unexpected copydata from server for {0}",
!                             op == null ? "null" : op.getClass().getName()), PSQLState.COMMUNICATION_ERROR);
                  } else {
                      ((CopyOutImpl)op).handleCopydata(buf);
                  }
--- 980,986 ----
                      error = new PSQLException(GT.tr("Got CopyData without an active copy operation"),
PSQLState.OBJECT_NOT_IN_STATE);
                  } else if (!(op instanceof CopyOutImpl)) {
                      error = new PSQLException(GT.tr("Unexpected copydata from server for {0}",
!                             op.getClass().getName()), PSQLState.COMMUNICATION_ERROR);
                  } else {
                      ((CopyOutImpl)op).handleCopydata(buf);
                  }
Index: org/postgresql/fastpath/Fastpath.java
===================================================================
RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/fastpath/Fastpath.java,v
retrieving revision 1.35
diff -c -r1.35 Fastpath.java
*** org/postgresql/fastpath/Fastpath.java    8 Jan 2008 06:56:28 -0000    1.35
--- org/postgresql/fastpath/Fastpath.java    20 Mar 2010 19:39:33 -0000
***************
*** 22,28 ****
  /**
   * This class implements the Fastpath api.
   *
!  * <p>This is a means of executing functions imbeded in the org.postgresql
   *  backend from within a java application.
   *
   * <p>It is based around the file src/interfaces/libpq/fe-exec.c
--- 22,28 ----
  /**
   * This class implements the Fastpath api.
   *
!  * <p>This is a means of executing functions embedded in the org.postgresql
   *  backend from within a java application.
   *
   * <p>It is based around the file src/interfaces/libpq/fe-exec.c

pgsql-jdbc by date:

Previous
From: Lew
Date:
Subject: Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed
Next
From: Kris Jurka
Date:
Subject: Re: Fix for a possible NPE