From 14074d3fcbf87037aea31ee360de95737bc44ac4 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Tue, 1 Sep 2026 17:57:20 -0400 Subject: [PATCH 1/2] fix: `dvobject.id` should be Bigint RoleTagRetriever.findDataverseIdsForFiles cast dvobject.id to Integer. That column is an integer in databases created by older releases but a bigint in newly created ones, so the JDBC driver returns a Long and the cast threw a ClassCastException, failing every My Data request whose results included a file. Read the value as a Number instead, which is correct for both column types and needs no migration. DvObjectServiceBean.getObjectPathsByIds had the same cast, where it silently skipped rows rather than throwing. Co-Authored-By: Claude Opus 5 (1M context) --- doc/release-notes/mydata-bigint-classcastexception.md | 7 +++++++ .../edu/harvard/iq/dataverse/DvObjectServiceBean.java | 4 ++-- .../edu/harvard/iq/dataverse/mydata/RoleTagRetriever.java | 8 +++----- 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 doc/release-notes/mydata-bigint-classcastexception.md diff --git a/doc/release-notes/mydata-bigint-classcastexception.md b/doc/release-notes/mydata-bigint-classcastexception.md new file mode 100644 index 00000000000..b342fb0b8a6 --- /dev/null +++ b/doc/release-notes/mydata-bigint-classcastexception.md @@ -0,0 +1,7 @@ +### My Data no longer fails when results include files + +On installations whose database was created recently, `dvobject.id` is a `bigint` column, so the +JDBC driver returns a `Long` for it. My Data read that value as an `Integer`, which made +`/api/mydata/retrieve` (and the My Data page) fail with a `ClassCastException` and an HTTP 500 +for any request whose results included a file. The value is now read as a `Number`, which is +correct whether the column is an `integer` (older databases) or a `bigint` (newer ones). diff --git a/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java index b62ba46c784..e846711f129 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/DvObjectServiceBean.java @@ -372,9 +372,9 @@ public Map getObjectPathsByIds(Set objectIds){ Long ownerId; if (result[0] != null) { try { - objectId = ((Integer) result[0]).longValue(); + objectId = ((Number) result[0]).longValue(); } catch (Exception ex) { - logger.warning("OBJECT PATH: could not cast result[0] (dvobject id) to Integer!"); + logger.warning("OBJECT PATH: could not cast result[0] (dvobject id) to Number!"); objectId = null; } if (objectId == null) { diff --git a/src/main/java/edu/harvard/iq/dataverse/mydata/RoleTagRetriever.java b/src/main/java/edu/harvard/iq/dataverse/mydata/RoleTagRetriever.java index c4f1e0e68ab..e63a97df449 100644 --- a/src/main/java/edu/harvard/iq/dataverse/mydata/RoleTagRetriever.java +++ b/src/main/java/edu/harvard/iq/dataverse/mydata/RoleTagRetriever.java @@ -331,19 +331,17 @@ private void findDataverseIdsForFiles(){ // ------------------------------------- // (3) Process the results -- the parent ID is the Dataverse that we're interested in // ------------------------------------- - Integer dvIdAsInteger; Long dvId; String dtype; Long parentId; - + // ------------------------------------- // Iterate through object list // ------------------------------------- for (Object[] ra : results) { - dvIdAsInteger = (Integer)ra[0]; // ?? Why, should be a Long - dvId = new Long(dvIdAsInteger); + dvId = ((Number)ra[0]).longValue(); dtype = (String)ra[1]; - parentId = (Long)ra[2]; + parentId = ((Number)ra[2]).longValue(); //msg("result: dvId: " + dvId + " |dtype: " + dtype + " |parentId: " + parentId); // Should ALWAYS be a Dataset! From 7112a2735d57d9160e183d48ebd06c50e29c6644 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Tue, 1 Sep 2026 18:13:05 -0400 Subject: [PATCH 2/2] remove file --- doc/release-notes/mydata-bigint-classcastexception.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 doc/release-notes/mydata-bigint-classcastexception.md diff --git a/doc/release-notes/mydata-bigint-classcastexception.md b/doc/release-notes/mydata-bigint-classcastexception.md deleted file mode 100644 index b342fb0b8a6..00000000000 --- a/doc/release-notes/mydata-bigint-classcastexception.md +++ /dev/null @@ -1,7 +0,0 @@ -### My Data no longer fails when results include files - -On installations whose database was created recently, `dvobject.id` is a `bigint` column, so the -JDBC driver returns a `Long` for it. My Data read that value as an `Integer`, which made -`/api/mydata/retrieve` (and the My Data page) fail with a `ClassCastException` and an HTTP 500 -for any request whose results included a file. The value is now read as a `Number`, which is -correct whether the column is an `integer` (older databases) or a `bigint` (newer ones).