Skip to content

Commit

Permalink
errorprone :: UnnecessaryDefaultInEnumSwitch
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-mlb committed May 24, 2024
1 parent 210526e commit c43d89a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/main/java/emissary/core/BaseDataObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.google.common.collect.LinkedListMultimap;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
Expand Down Expand Up @@ -375,10 +376,8 @@ public SeekableByteChannelFactory getChannelFactory() {
return seekableByteChannelFactory;
case BYTE_ARRAY_ONLY:
return SeekableByteChannelHelper.memory(this.theData);
case NO_DATA:
default:
return null;
}
return null;
}

/**
Expand Down Expand Up @@ -427,10 +426,8 @@ public byte[] data() {
safeUsageChecker.recordSnapshot(bytes);

return bytes;
case NO_DATA:
default:
return null; // NOSONAR maintains backwards compatibility
}
return null;
}

/**
Expand Down Expand Up @@ -495,15 +492,13 @@ public long getChannelSize() throws IOException {
case BYTE_ARRAY_AND_CHANNEL:
throw new IllegalStateException(String.format(INVALID_STATE_MSG, shortName()));
case BYTE_ARRAY_ONLY:
return theData.length;
return ArrayUtils.getLength(theData);
case CHANNEL_ONLY:
try (final SeekableByteChannel sbc = this.seekableByteChannelFactory.create()) {
return sbc.size();
}
case NO_DATA:
default:
return 0;
}
return 0;
}

/**
Expand All @@ -518,18 +513,17 @@ public int dataLength() {
case BYTE_ARRAY_AND_CHANNEL:
throw new IllegalStateException(String.format(INVALID_STATE_MSG, shortName()));
case BYTE_ARRAY_ONLY:
return theData.length;
return ArrayUtils.getLength(theData);
case CHANNEL_ONLY:
try {
return (int) Math.min(getChannelSize(), MAX_BYTE_ARRAY_SIZE);
} catch (final IOException ioe) {
logger.error("Couldn't get size of channel on object {}", shortName(), ioe);
return 0;
}
case NO_DATA:
default:
return 0;
}

return 0;
}

@Override
Expand Down

0 comments on commit c43d89a

Please sign in to comment.