Skip to content

Commit

Permalink
MCR-3224 activate PMD rule AvoidMessageDigestField
Browse files Browse the repository at this point in the history
  • Loading branch information
yagee-de committed Nov 19, 2024
1 parent fd47c7c commit 559cb7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* provides the header of the file that is read (the first 64k) for content type
* detection purposes, counts the number of bytes read and builds an MD5
* checksum String while content goes through this input stream.
*
*
* @author Frank Lützenkirchen
*/
public class MCRContentInputStream extends FilterInputStream {
Expand All @@ -46,6 +46,7 @@ public class MCRContentInputStream extends FilterInputStream {
protected byte[] md5 = null;

/** The message digest to build the MD5 checksum */
@SuppressWarnings("PMD.AvoidMessageDigestField") //InputStream is not thread safe either
protected MessageDigest digest = null;

/** The total number of bytes read so far */
Expand All @@ -56,7 +57,7 @@ public class MCRContentInputStream extends FilterInputStream {

/**
* Constructs a new MCRContentInputStream
*
*
* @param in
* the InputStream to read from
* @throws MCRConfigurationException
Expand Down Expand Up @@ -138,7 +139,7 @@ public int read(byte[] buf, int off, int len) throws IOException {
/**
* Returns the first 64 k of the underlying input stream. This is used for
* content type detection during file import into MyCoRe.
*
*
* @return the first 64 k of the input stream
*/
public byte[] getHeader() {
Expand All @@ -147,7 +148,7 @@ public byte[] getHeader() {

/**
* Returns the number of bytes read so far
*
*
* @return the number of bytes read
*/
public long getLength() {
Expand All @@ -157,7 +158,7 @@ public long getLength() {
/**
* Returns the MD5 message digest that has been built during reading of the
* underlying input stream.
*
*
* @return the MD5 message digest checksum of all bytes that have been read
*/
public byte[] getMD5() {
Expand All @@ -169,7 +170,7 @@ public byte[] getMD5() {

/**
* Returns the MD5 checksum as a String
*
*
* @return the MD5 checksum as a String of hex digits
*/
public String getMD5String() {
Expand All @@ -178,7 +179,7 @@ public String getMD5String() {

/**
* Given an MD5 message digest, returns the MD5 checksum as a String
*
*
* @return the MD5 checksum as a String of hex digits
*/
public static String getMD5String(byte[] digest) {
Expand All @@ -191,7 +192,7 @@ public static String getMD5String(byte[] digest) {

/**
* Builds a MessageDigest instance for MD5 checksum computation.
*
*
* @throws MCRConfigurationException
* if no java classes that support MD5 algorithm could be found
*/
Expand Down
3 changes: 0 additions & 3 deletions ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
<!-- Best Practices Rules -->
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod"/>
<rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly"/>
<!-- TODO: Create PR to fix this rule -->
<!--
<rule ref="category/java/bestpractices.xml/AvoidMessageDigestField"/>
-->
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
<rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables"/>
<!-- TODO: Create PR to fix this rule -->
Expand Down

0 comments on commit 559cb7b

Please sign in to comment.