Skip to content

Commit e67c600

Browse files
authored
Merge pull request #8095 from dCache/issue8071-11.2
chimera: fix reading of empty tags
2 parents 3f073eb + 9b4b56f commit e67c600

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

modules/chimera/src/main/java/org/dcache/chimera/FsSqlDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,8 @@ int getTag(FsInode inode, String tagName, byte[] data, int offset, int len)
15071507
/* some databases (hsqldb in particular) fill a full record for
15081508
* BLOBs and on read reads a full record, which is not what we expect.
15091509
*/
1510-
return in.readNBytes(data, offset,
1510+
// If tag is not set or NULL, then getBinaryStream will return null.
1511+
return in == null ? 0 : in.readNBytes(data, offset,
15111512
Math.min(len, (int) rs.getLong("isize")));
15121513
} catch (IOException e) {
15131514
throw new LobRetrievalFailureException(e.getMessage(), e);

modules/chimera/src/test/java/org/dcache/chimera/JdbcFsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,16 @@ public void testPushTag() throws Exception {
16481648
assertArrayEquals(new String[]{tagName}, _fs.tags(d));
16491649
}
16501650

1651+
@Test
1652+
public void testReadNullTag() throws Exception {
1653+
1654+
FsInode top = _rootInode.mkdir("top");
1655+
_fs.createTag(top, "aTag");
1656+
1657+
int n = _fs.getTag(top, "aTag", new byte[10], 0, 10);
1658+
assertThat("Tag without content should return zero bytes", n, is(0));
1659+
}
1660+
16511661
@Test
16521662
public void testTashTimestampOnRemove() throws Exception {
16531663
final String name = "testTashTimestampOnRemove";

0 commit comments

Comments
 (0)