db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fernanda Pizzorno (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1177) updateObject with null as argument causes network driver to fail with NullPointerException
Date Wed, 05 Apr 2006 12:08:48 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1177?page=comments#action_12373270 ] 

Fernanda Pizzorno commented on DERBY-1177:
------------------------------------------

I have reviewed the patch and I have some comments:

1. lang/updatableResultSet.java

The behaviour of the method updateObject(columnIndex/Name, x) has been changed in the client
driver so that it will no longer throw and exception when it is used with x = null. The cannons
have been updated, but the test has not been updated, so it still gives the impresion that
an exception is expected for DerbyNetClient:

try {
if (indexOrName == 1) //test by passing column position
	rs.updateObject(sqlType, null);
else //test by passing column name
	rs.updateObject(ColumnNames[sqlType-1], null);
} catch (Throwable e) {
if (TestUtil.isNetFramework()) {
	System.out.println("   Got expected exception:" + e.getMessage());
	continue;
} else {
	System.out.println("   Got UNexpected exception:" + e.getMessage());
	return;
}
}

I think it would be better if "Got UNexpected exception: ..." was being printed out when the
framework is DerbyNetClient.

2. I run the following test:

rs = updatableStatement.executeQuery("select * from tmpResultSet where id < 100");
rs.next()
rs.updateObject(1, null);
System.out.println("Value of column 1 after updateObject(1, null): " + rs.getInt(1));
System.out.println("Was null: " + rs.wasNull());
rs.updateNull(1);
System.out.println("Value of column 1 after updateNull(1): " + rs.getInt(1));
System.out.println("Was null: " + rs.wasNull());
rs.updateInt(1, rs.getInt(1) + 100);
System.out.println("Value of column 1 after updateInt(1): " + rs.getInt(1));
System.out.println("Was null: " + rs.wasNull());

and I got the following result:

Value of column 1 after updateObject(1, null): 1
Was null: false
Value of column 1 after updateNull(1): 1
Was null: false
Value of column 1 after updateInt(1): 101
Was null: false

when I expected to get:

Value of column 1 after updateObject(1, null): 0
Was null: true
Value of column 1 after updateNull(1): 0
Was null: true
Value of column 1 after updateInt(1): 100
Was null: false

I can see that updateNull also has an incorrect behaviour, but I think that if you are going
to change the behaviour of updateObject so that it will allow to update the column to null,
you should make make sure that subsequent calls to getter and wasNull method will return the
correct values.

If you can fix the behaviour of updateNull at the same time, it would be nice :). One less
difference in behaviour between Embedded and Client drivers.


> updateObject with null as argument causes network driver to fail with NullPointerException
> ------------------------------------------------------------------------------------------
>
>          Key: DERBY-1177
>          URL: http://issues.apache.org/jira/browse/DERBY-1177
>      Project: Derby
>         Type: Bug

>   Components: Network Client
>     Versions: 10.2.0.0
>     Reporter: Andreas Korneliussen
>     Assignee: Andreas Korneliussen
>     Priority: Minor
>  Attachments: DERBY-1177.diff, DERBY-1177.stat, UpdateXXXTest.java, derbyall_report.txt
>
> Calling ResultSet.updateObject(column, object) causes the network driver to give NullPointerException
if the object parameter is null.
> Stack trace from test:
> Test output:
> ........E.
> Time: 7.597
> There was 1 error:
> 1) testUpdateObjectWithNull(org.apache.derbyTesting.functionTests.tests.jdbcapi.UpdateXXXTest)java.lang.NullPointerException
>         at org.apache.derby.client.am.CrossConverters.setObject(CrossConverters.java:845)
>         at org.apache.derby.client.am.ResultSet.updateObject(ResultSet.java:3073)
>         at org.apache.derbyTesting.functionTests.tests.jdbcapi.UpdateXXXTest.testUpdateObjectWithNull(UpdateXXXTest.java:215)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> Will attach the test.
> To run:
> java -Dframework=DerbyNetClient org.apache.derbyTesting.functionTests.harness.RunTest
jdbcapi/UpdateXXXTest.junit
> The test does not fail with the embedded framework.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message