String.valuOf(null) return "null" string by contract.

On Thu, Nov 3, 2016 at 5:33 PM, Anil <[email protected]> wrote:

> HI ,
>
> null values are returned as "null" with ignite jdbc result set.
>
>  private <T> T getTypedValue(int colIdx, Class<T> cls) throws SQLException
> {
>         ensureNotClosed();
>         ensureHasCurrentRow();
>
>         try {
>             T val = cls == String.class ? (T)String.valueOf(curr.get(colIdx
> - 1)) : (T)curr.get(colIdx - 1);
>
>             wasNull = val == null;
>
>             return val;
>         }
>         catch (IndexOutOfBoundsException ignored) {
>             throw new SQLException("Invalid column index: " + colIdx);
>         }
>         catch (ClassCastException ignored) {
>             throw new SQLException("Value is an not instance of " +
> cls.getName());
>         }
>     }
>
>
> if a column value is null (curr.get(colIdx - 1) return null but
> String.valueOf( (curr.get(colIdx - 1) ) is not null it is "null".
>
> ArrayList<String> obj = new ArrayList<String>();
>                           obj.add(null);
> System.out.println(null == (String)String.valueOf(obj.get(0)));
>
> above Sysout is false.
>
> Fix :
>
> Object colValue = curr.get(colIdx - 1);
>
> T val = cls == String.class ? (String) colValue : (T) colValue;
>
> or return (T) colValue
>
>
> please let me know if you see any issues. thanks
>
>
>

Reply via email to