From a43efeab66cc22d83443fb6033edd99cf618a796 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 20 Feb 2019 18:50:33 -0500 Subject: [PATCH] use java style array declaration instead of C style --- .../java/hudson/model/UsageStatistics.java | 2 +- .../tools/AbstractCommandInstaller.java | 2 +- .../java/hudson/util/AtomicFileWriter.java | 2 +- .../src/main/java/hudson/util/ByteBuffer.java | 4 ++-- core/src/main/java/hudson/util/CharSpool.java | 2 +- .../java/hudson/util/ChunkedInputStream.java | 2 +- .../java/hudson/util/ChunkedOutputStream.java | 24 +++++++++++-------- .../java/hudson/util/FileChannelWriter.java | 2 +- .../java/hudson/util/HeadBufferingStream.java | 2 +- .../hudson/util/LineEndNormalizingWriter.java | 4 ++-- .../src/main/java/hudson/util/NullStream.java | 4 ++-- .../java/hudson/util/WriterOutputStream.java | 2 +- .../validator/routines/DomainValidator.java | 2 +- .../jenkins/util/MarkFindingOutputStream.java | 2 +- 14 files changed, 30 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/hudson/model/UsageStatistics.java b/core/src/main/java/hudson/model/UsageStatistics.java index e0da52671b..b7db2419c7 100644 --- a/core/src/main/java/hudson/model/UsageStatistics.java +++ b/core/src/main/java/hudson/model/UsageStatistics.java @@ -159,7 +159,7 @@ public class UsageStatistics extends PageDecorator implements PersistentDescript // capture the descriptors as these should be small compared with the number of items // so we will walk all items only once and we can short-cut the search of descriptors TopLevelItemDescriptor[] descriptors = Items.all().toArray(new TopLevelItemDescriptor[0]); - int counts[] = new int[descriptors.length]; + int[] counts = new int[descriptors.length]; for (TopLevelItem item: j.allItems(TopLevelItem.class)) { TopLevelItemDescriptor d = item.getDescriptor(); for (int i = 0; i < descriptors.length; i++) { diff --git a/core/src/main/java/hudson/tools/AbstractCommandInstaller.java b/core/src/main/java/hudson/tools/AbstractCommandInstaller.java index f104e18521..c174f024c5 100644 --- a/core/src/main/java/hudson/tools/AbstractCommandInstaller.java +++ b/core/src/main/java/hudson/tools/AbstractCommandInstaller.java @@ -73,7 +73,7 @@ public abstract class AbstractCommandInstaller extends ToolInstaller { // TODO support Unix scripts with interpreter line (see Shell.buildCommandLine) FilePath script = dir.createTextTempFile("hudson", getCommandFileExtension(), command); try { - String cmd[] = getCommandCall(script); + String[] cmd = getCommandCall(script); int r = node.createLauncher(log).launch().cmds(cmd).stdout(log).pwd(dir).join(); if (r != 0) { throw new IOException("Command returned status " + r); diff --git a/core/src/main/java/hudson/util/AtomicFileWriter.java b/core/src/main/java/hudson/util/AtomicFileWriter.java index a2fae13bac..c3da305885 100644 --- a/core/src/main/java/hudson/util/AtomicFileWriter.java +++ b/core/src/main/java/hudson/util/AtomicFileWriter.java @@ -162,7 +162,7 @@ public class AtomicFileWriter extends Writer { core.write(str,off,len); } - public void write(char cbuf[], int off, int len) throws IOException { + public void write(char[] cbuf, int off, int len) throws IOException { core.write(cbuf,off,len); } diff --git a/core/src/main/java/hudson/util/ByteBuffer.java b/core/src/main/java/hudson/util/ByteBuffer.java index 8281ce25c6..2749421adf 100644 --- a/core/src/main/java/hudson/util/ByteBuffer.java +++ b/core/src/main/java/hudson/util/ByteBuffer.java @@ -46,7 +46,7 @@ public class ByteBuffer extends OutputStream { private int size = 0; - public synchronized void write(byte b[], int off, int len) throws IOException { + public synchronized void write(byte[] b, int off, int len) throws IOException { ensureCapacity(len); System.arraycopy(b,off,buf,size,len); size+=len; @@ -94,7 +94,7 @@ public class ByteBuffer extends OutputStream { } } - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { synchronized(ByteBuffer.this) { if(size==pos) return -1; diff --git a/core/src/main/java/hudson/util/CharSpool.java b/core/src/main/java/hudson/util/CharSpool.java index c27a74cb6f..6ab9c531d6 100644 --- a/core/src/main/java/hudson/util/CharSpool.java +++ b/core/src/main/java/hudson/util/CharSpool.java @@ -41,7 +41,7 @@ public final class CharSpool extends Writer { private char[] last = new char[1024]; private int pos; - public void write(char cbuf[], int off, int len) { + public void write(char[] cbuf, int off, int len) { while(len>0) { int sz = Math.min(last.length-pos,len); System.arraycopy(cbuf,off,last,pos,sz); diff --git a/core/src/main/java/hudson/util/ChunkedInputStream.java b/core/src/main/java/hudson/util/ChunkedInputStream.java index 0ae926f75c..6bd1fa450b 100644 --- a/core/src/main/java/hudson/util/ChunkedInputStream.java +++ b/core/src/main/java/hudson/util/ChunkedInputStream.java @@ -342,7 +342,7 @@ public class ChunkedInputStream extends InputStream { */ static void exhaustInputStream(InputStream inStream) throws IOException { // read and discard the remainder of the message - byte buffer[] = new byte[1024]; + byte[] buffer = new byte[1024]; while (inStream.read(buffer) >= 0) { ; } diff --git a/core/src/main/java/hudson/util/ChunkedOutputStream.java b/core/src/main/java/hudson/util/ChunkedOutputStream.java index e96295afd8..58fb736b98 100644 --- a/core/src/main/java/hudson/util/ChunkedOutputStream.java +++ b/core/src/main/java/hudson/util/ChunkedOutputStream.java @@ -42,13 +42,17 @@ import java.io.OutputStream; public class ChunkedOutputStream extends OutputStream { // ------------------------------------------------------- Static Variables - private static final byte CRLF[] = new byte[] {(byte) 13, (byte) 10}; + private static final byte[] CRLF = new byte[]{(byte) 13, (byte) 10}; - /** End chunk */ - private static final byte ENDCHUNK[] = CRLF; + /** + * End chunk + */ + private static final byte[] ENDCHUNK = CRLF; - /** 0 */ - private static final byte ZERO[] = new byte[] {(byte) '0'}; + /** + * 0 + */ + private static final byte[] ZERO = new byte[]{(byte) '0'}; // ----------------------------------------------------- Instance Variables private OutputStream stream = null; @@ -92,7 +96,7 @@ public class ChunkedOutputStream extends OutputStream { */ protected void flushCache() throws IOException { if (cachePosition > 0) { - byte chunkHeader[] = (Integer.toHexString(cachePosition) + "\r\n").getBytes("US-ASCII"); + byte[] chunkHeader = (Integer.toHexString(cachePosition) + "\r\n").getBytes("US-ASCII"); stream.write(chunkHeader, 0, chunkHeader.length); stream.write(cache, 0, cachePosition); stream.write(ENDCHUNK, 0, ENDCHUNK.length); @@ -110,8 +114,8 @@ public class ChunkedOutputStream extends OutputStream { * * @since 3.0 */ - protected void flushCacheWithAppend(byte bufferToAppend[], int off, int len) throws IOException { - byte chunkHeader[] = (Integer.toHexString(cachePosition + len) + "\r\n").getBytes("US-ASCII"); + protected void flushCacheWithAppend(byte[] bufferToAppend, int off, int len) throws IOException { + byte[] chunkHeader = (Integer.toHexString(cachePosition + len) + "\r\n").getBytes("US-ASCII"); stream.write(chunkHeader, 0, chunkHeader.length); stream.write(cache, 0, cachePosition); stream.write(bufferToAppend, off, len); @@ -167,12 +171,12 @@ public class ChunkedOutputStream extends OutputStream { * @since 3.0 */ @Override - public void write(byte b[]) throws IOException { + public void write(byte[] b) throws IOException { this.write(b, 0, b.length); } @Override - public void write(byte src[], int off, int len) throws IOException { + public void write(byte[] src, int off, int len) throws IOException { if (len >= cache.length - cachePosition) { flushCacheWithAppend(src, off, len); } else { diff --git a/core/src/main/java/hudson/util/FileChannelWriter.java b/core/src/main/java/hudson/util/FileChannelWriter.java index 8d623740d1..0028e62411 100644 --- a/core/src/main/java/hudson/util/FileChannelWriter.java +++ b/core/src/main/java/hudson/util/FileChannelWriter.java @@ -66,7 +66,7 @@ public class FileChannelWriter extends Writer { } @Override - public void write(char cbuf[], int off, int len) throws IOException { + public void write(char[] cbuf, int off, int len) throws IOException { final CharBuffer charBuffer = CharBuffer.wrap(cbuf, off, len); ByteBuffer byteBuffer = charset.encode(charBuffer); channel.write(byteBuffer); diff --git a/core/src/main/java/hudson/util/HeadBufferingStream.java b/core/src/main/java/hudson/util/HeadBufferingStream.java index 64240c7840..0b243e575d 100644 --- a/core/src/main/java/hudson/util/HeadBufferingStream.java +++ b/core/src/main/java/hudson/util/HeadBufferingStream.java @@ -57,7 +57,7 @@ public class HeadBufferingStream extends FilterInputStream { } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { int r = in.read(b, off, len); if(r>0) { int sp = space(); diff --git a/core/src/main/java/hudson/util/LineEndNormalizingWriter.java b/core/src/main/java/hudson/util/LineEndNormalizingWriter.java index 480f71d459..b8ad5c182b 100644 --- a/core/src/main/java/hudson/util/LineEndNormalizingWriter.java +++ b/core/src/main/java/hudson/util/LineEndNormalizingWriter.java @@ -48,7 +48,7 @@ public class LineEndNormalizingWriter extends FilterWriter { super(out); } - public void write(char cbuf[]) throws IOException { + public void write(char[] cbuf) throws IOException { write(cbuf, 0, cbuf.length); } @@ -64,7 +64,7 @@ public class LineEndNormalizingWriter extends FilterWriter { seenCR = (c==CR); } - public void write(char cbuf[], int off, int len) throws IOException { + public void write(char[] cbuf, int off, int len) throws IOException { int end = off+len; int writeBegin = off; diff --git a/core/src/main/java/hudson/util/NullStream.java b/core/src/main/java/hudson/util/NullStream.java index e23a9d052e..3eca6690f8 100644 --- a/core/src/main/java/hudson/util/NullStream.java +++ b/core/src/main/java/hudson/util/NullStream.java @@ -32,11 +32,11 @@ public final class NullStream extends OutputStream { public NullStream() {} @Override - public void write(byte b[]) { + public void write(byte[] b) { } @Override - public void write(byte b[], int off, int len) { + public void write(byte[] b, int off, int len) { } public void write(int b) { diff --git a/core/src/main/java/hudson/util/WriterOutputStream.java b/core/src/main/java/hudson/util/WriterOutputStream.java index a73bbfa45f..d3e25b4c04 100644 --- a/core/src/main/java/hudson/util/WriterOutputStream.java +++ b/core/src/main/java/hudson/util/WriterOutputStream.java @@ -62,7 +62,7 @@ public class WriterOutputStream extends OutputStream { buf.put((byte)b); } - public void write(byte b[], int off, int len) throws IOException { + public void write(byte[] b, int off, int len) throws IOException { while(len>0) { if(buf.remaining()==0) decode(false); diff --git a/core/src/main/java/jenkins/org/apache/commons/validator/routines/DomainValidator.java b/core/src/main/java/jenkins/org/apache/commons/validator/routines/DomainValidator.java index e23c8f15a1..90ca16002b 100644 --- a/core/src/main/java/jenkins/org/apache/commons/validator/routines/DomainValidator.java +++ b/core/src/main/java/jenkins/org/apache/commons/validator/routines/DomainValidator.java @@ -1961,7 +1961,7 @@ public class DomainValidator implements Serializable { * @since 1.5.1 */ public static String [] getTLDEntries(DomainValidator.ArrayType table) { - final String array[]; + final String[] array; switch(table) { case COUNTRY_CODE_MINUS: array = countryCodeTLDsMinus; diff --git a/core/src/main/java/jenkins/util/MarkFindingOutputStream.java b/core/src/main/java/jenkins/util/MarkFindingOutputStream.java index 6fa43659c6..dd0e5c971d 100644 --- a/core/src/main/java/jenkins/util/MarkFindingOutputStream.java +++ b/core/src/main/java/jenkins/util/MarkFindingOutputStream.java @@ -46,7 +46,7 @@ public abstract class MarkFindingOutputStream extends OutputStream { } } - public void write(byte b[], int off, int len) throws IOException { + public void write(byte[] b, int off, int len) throws IOException { final int start = off; final int end = off + len; for (int i=off; i