Skip to content

NullPointerException when the column value is NULL #90

Description

@IrfanMusaKhan

When a column is null, following method in CursorWindow.java has null pointer exception.

E/AndroidRuntime(11321): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'char[] java.lang.String.toCharArray()' on a null object reference
E/AndroidRuntime(11321): at net.zetetic.database.CursorWindow.copyStringToBuffer
    public void copyStringToBuffer(int row, int column, CharArrayBuffer buffer) {
		if (buffer == null) {
			throw new IllegalArgumentException("CharArrayBuffer should not be null");
		}
		// TODO not as optimal as the original code
		char[] chars = getString(row, column).toCharArray(); < ---------- NPE
		buffer.data = chars;
		buffer.sizeCopied = chars.length;
	}

There is another copyStringToBuffer method in AbstractCursor.java which is safer than the one which has NPE.

Tests in AbstractCursorTest.java are ignored without any reason.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions