Skip to content

Commit cbb575a

Browse files
committed
sonarqube cleanup.
1 parent 5155cd8 commit cbb575a

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/main/java/org/hdf5javalib/dataclass/reference/HdfSelectPointsV1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public HdfDataHolder getData(HdfDataObject hdfDataObject, HdfDataFile hdfDataFil
7272
// 2. For efficient O(1) lookups, convert the target int[][] coordinates to a Set<List<Integer>>.
7373
// A List<Integer> has a content-based hashCode/equals, unlike int[].
7474
Set<List<Integer>> targetPointsSet = Arrays.stream(this.values)
75-
.map(pointCoords -> Arrays.stream(pointCoords).boxed().collect(Collectors.toList()))
75+
.map(pointCoords -> Arrays.stream(pointCoords).boxed().toList())
7676
.collect(Collectors.toSet());
7777

7878
// 3. Get the flattened data source stream.

src/main/java/org/hdf5javalib/datatype/CompoundDatatype.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ public String toString() {
268268
*/
269269
@Override
270270
public int getSizeMessageData() {
271-
short size = 8; // Header size
271+
short hdrSize = 8; // Header size
272272
for (CompoundMemberDatatype member : members) {
273-
size += member.getSizeMessageData();
273+
hdrSize += member.getSizeMessageData();
274274
}
275-
return size;
275+
return hdrSize;
276276
}
277277

278278
/**
@@ -353,7 +353,7 @@ public <T> T toPOJO(Class<T> clazz, byte[] bytes) {
353353
}
354354
return instance;
355355
} catch (Exception e) {
356-
throw new RuntimeException("Failed to create instance of " + clazz.getName(), e);
356+
throw new IllegalStateException("Failed to create instance of " + clazz.getName(), e);
357357
}
358358
}
359359

@@ -372,8 +372,7 @@ private Map<String, CompoundMemberDatatype> getCachedMemberMap() {
372372

373373
// Extracted record creation logic with caching
374374
private <T> T createRecordInstance(Class<T> clazz, byte[] bytes,
375-
Map<String, CompoundMemberDatatype> nameToMemberMap)
376-
throws Exception {
375+
Map<String, CompoundMemberDatatype> nameToMemberMap) throws InvocationTargetException, InstantiationException, IllegalAccessException {
377376

378377
// Cache record components
379378
RecordComponent[] components = CLASS_RECORD_COMPONENTS_CACHE.computeIfAbsent(clazz,
@@ -391,7 +390,7 @@ private <T> T createRecordInstance(Class<T> clazz, byte[] bytes,
391390
ctor.setAccessible(true);
392391
return ctor;
393392
} catch (NoSuchMethodException e) {
394-
throw new RuntimeException("No canonical constructor found for record: " + clazz.getName(), e);
393+
throw new IllegalStateException("No canonical constructor found for record: " + clazz.getName(), e);
395394
}
396395
});
397396

@@ -417,8 +416,7 @@ private <T> T createRecordInstance(Class<T> clazz, byte[] bytes,
417416
// Extracted class creation logic with caching
418417
private <T> T createClassInstance(Class<T> clazz, byte[] bytes,
419418
Map<String, Field> nameToFieldMap,
420-
Map<String, CompoundMemberDatatype> nameToMemberMap)
421-
throws Exception {
419+
Map<String, CompoundMemberDatatype> nameToMemberMap) throws InvocationTargetException, InstantiationException, IllegalAccessException {
422420

423421
// Cache no-arg constructor
424422
@SuppressWarnings("unchecked")
@@ -433,7 +431,7 @@ private <T> T createClassInstance(Class<T> clazz, byte[] bytes,
433431
Constructor<?> fallback = Arrays.stream(constructors)
434432
.filter(ct -> ct.getParameterCount() <= nameToMemberMap.size())
435433
.findFirst()
436-
.orElseThrow(() -> new RuntimeException("No suitable constructor for " + clazz.getName()));
434+
.orElseThrow(() -> new IllegalStateException("No suitable constructor for " + clazz.getName()));
437435
fallback.setAccessible(true);
438436
return fallback;
439437
}

0 commit comments

Comments
 (0)