Skip to content

Commit e123a60

Browse files
committed
Replaces C-style array declarations with Java-style ones
Signed-off-by: Otavio R. Piske <angusyoung@gmail.com>
1 parent f30e10b commit e123a60

11 files changed

Lines changed: 32 additions & 32 deletions

File tree

org.eclipse.paho.client.mqttv3.test/src/test/java/org/eclipse/paho/client/mqttv3/test/utilities/MqttV3Receiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public boolean validateReceipt(List<String> sendTopics, List<Integer> expectedQo
204204
log.entering(className, methodName, new Object[]{
205205
sendTopics, expectedQosList, sentBytes});
206206

207-
int expectedMessageNumbers[] = new int[nPublishers];
207+
int[] expectedMessageNumbers = new int[nPublishers];
208208
for (int i = 0; i < nPublishers; i++) {
209209
expectedMessageNumbers[i] = 0;
210210
}

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/security/SSLSocketFactoryFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ public class SSLSocketFactoryFactory {
133133

134134

135135
public static final String DEFAULT_PROTOCOL = "TLS"; // "SSL_TLS" is not supported by DesktopEE
136-
137-
private static final String propertyKeys[] = { SSLPROTOCOL, JSSEPROVIDER,
138-
KEYSTORE, KEYSTOREPWD, KEYSTORETYPE, KEYSTOREPROVIDER, KEYSTOREMGR,
139-
TRUSTSTORE, TRUSTSTOREPWD, TRUSTSTORETYPE, TRUSTSTOREPROVIDER,
140-
TRUSTSTOREMGR, CIPHERSUITES, CLIENTAUTH};
136+
137+
private static final String[] propertyKeys = {SSLPROTOCOL, JSSEPROVIDER,
138+
KEYSTORE, KEYSTOREPWD, KEYSTORETYPE, KEYSTOREPROVIDER, KEYSTOREMGR,
139+
TRUSTSTORE, TRUSTSTOREPWD, TRUSTSTORETYPE, TRUSTSTOREPROVIDER,
140+
TRUSTSTOREMGR, CIPHERSUITES, CLIENTAUTH};
141141

142142
private Hashtable configs; // a hashtable that maps configIDs to properties.
143143

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/websocket/WebSocketFrame.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class WebSocketFrame {
2626

2727
private byte opcode;
2828
private boolean fin;
29-
private byte payload[];
29+
private byte[] payload;
3030
private boolean closeFlag = false;
3131

3232
public byte getOpcode() {
@@ -97,7 +97,7 @@ public WebSocketFrame(byte[] rawFrame) {
9797
}
9898

9999
// Get the Masking key if masked
100-
byte maskingKey[] = null;
100+
byte[] maskingKey = null;
101101
if (masked) {
102102
maskingKey = new byte[4];
103103
buffer.get(maskingKey, 0, 4);
@@ -163,7 +163,7 @@ public WebSocketFrame(InputStream input) throws IOException {
163163
}
164164

165165
// Get the masking key
166-
byte maskingKey[] = null;
166+
byte[] maskingKey = null;
167167
if (masked) {
168168
maskingKey = new byte[4];
169169
input.read(maskingKey, 0, 4);
@@ -211,7 +211,7 @@ public byte[] encodeFrame() {
211211

212212
ByteBuffer buffer = ByteBuffer.allocate(length);
213213
appendFinAndOpCode(buffer, this.opcode, this.fin);
214-
byte mask[] = generateMaskingKey();
214+
byte[] mask = generateMaskingKey();
215215
appendLengthAndMask(buffer, this.payload.length, mask);
216216

217217
for (int i = 0; i < this.payload.length; i++) {
@@ -232,7 +232,7 @@ public byte[] encodeFrame() {
232232
* @param mask
233233
* The WebSocket Mask
234234
*/
235-
public static void appendLengthAndMask(ByteBuffer buffer, int length, byte mask[]) {
235+
public static void appendLengthAndMask(ByteBuffer buffer, int length, byte[] mask) {
236236
if (mask != null) {
237237
appendLength(buffer, length, true);
238238
buffer.put(mask);

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/wire/MqttWireMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public abstract class MqttWireMessage {
5151

5252
protected static final Charset STRING_ENCODING = StandardCharsets.UTF_8;
5353

54-
private static final String PACKET_NAMES[] = { "reserved", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC",
54+
private static final String[] PACKET_NAMES = {"reserved", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC",
5555
"PUBREL", "PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK", "PINGREQ", "PINGRESP",
56-
"DISCONNECT" };
56+
"DISCONNECT"};
5757

5858

5959
private static final long FOUR_BYTE_INT_MAX = 4294967295L;

org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/logging/SimpleLogFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String format(LogRecord r) {
4949
if (cnl>20) {
5050
cn = r.getSourceClassName().substring(cnl-19);
5151
} else {
52-
char sp[] = {' '};
52+
char[] sp = {' '};
5353
StringBuffer sb1= new StringBuffer().append(cnm);
5454
cn = sb1.append(sp,0, 1).toString();
5555
}

org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/logging/SimpleLogFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String format(LogRecord r) {
4949
if (cnl>20) {
5050
cn = r.getSourceClassName().substring(cnl-19);
5151
} else {
52-
char sp[] = {' '};
52+
char[] sp = {' '};
5353
StringBuffer sb1= new StringBuffer().append(cnm);
5454
cn = sb1.append(sp,0, 1).toString();
5555
}

org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/security/SSLSocketFactoryFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ public class SSLSocketFactoryFactory {
133133

134134

135135
public static final String DEFAULT_PROTOCOL = "TLS"; // "SSL_TLS" is not supported by DesktopEE
136-
137-
private static final String propertyKeys[] = { SSLPROTOCOL, JSSEPROVIDER,
138-
KEYSTORE, KEYSTOREPWD, KEYSTORETYPE, KEYSTOREPROVIDER, KEYSTOREMGR,
139-
TRUSTSTORE, TRUSTSTOREPWD, TRUSTSTORETYPE, TRUSTSTOREPROVIDER,
136+
137+
private static final String[] propertyKeys = {SSLPROTOCOL, JSSEPROVIDER,
138+
KEYSTORE, KEYSTOREPWD, KEYSTORETYPE, KEYSTOREPROVIDER, KEYSTOREMGR,
139+
TRUSTSTORE, TRUSTSTOREPWD, TRUSTSTORETYPE, TRUSTSTOREPROVIDER,
140140
TRUSTSTOREMGR, CIPHERSUITES, CLIENTAUTH};
141141

142142
private Hashtable<String, Properties> configs; // a hashtable that maps configIDs to properties.

org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/websocket/WebSocketFrame.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class WebSocketFrame {
2626

2727
private byte opcode;
2828
private boolean fin;
29-
private byte payload[];
29+
private byte[] payload;
3030
private boolean closeFlag = false;
3131

3232
public byte getOpcode() {
@@ -91,7 +91,7 @@ public WebSocketFrame (byte[] rawFrame){
9191
}
9292

9393
// Get the Masking key if masked
94-
byte maskingKey[] = null;
94+
byte[] maskingKey = null;
9595
if(masked) {
9696
maskingKey = new byte[4];
9797
buffer.get(maskingKey,0,4);
@@ -155,7 +155,7 @@ public WebSocketFrame(InputStream input) throws IOException {
155155
}
156156

157157
// Get the masking key
158-
byte maskingKey[] = null;
158+
byte[] maskingKey = null;
159159
if(masked) {
160160
maskingKey = new byte[4];
161161
input.read(maskingKey,0,4);
@@ -206,7 +206,7 @@ public byte[] encodeFrame(){
206206

207207
ByteBuffer buffer = ByteBuffer.allocate(length);
208208
appendFinAndOpCode(buffer, this.opcode, this.fin);
209-
byte mask[] = generateMaskingKey();
209+
byte[] mask = generateMaskingKey();
210210
appendLengthAndMask(buffer, this.payload.length, mask);
211211

212212
for(int i = 0; i < this.payload.length; i ++){
@@ -223,7 +223,7 @@ public byte[] encodeFrame(){
223223
* @param length the length of the frame
224224
* @param mask The WebSocket Mask
225225
*/
226-
public static void appendLengthAndMask(ByteBuffer buffer, int length, byte mask[]){
226+
public static void appendLengthAndMask(ByteBuffer buffer, int length, byte[] mask){
227227
if(mask != null){
228228
appendLength(buffer, length, true);
229229
buffer.put(mask);

org.eclipse.paho.mqttv5.client/src/test/java/org/eclipse/paho/mqttv5/client/test/utilities/MqttV5Receiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public boolean validateReceipt(List<String> sendTopics, List<Integer> expectedQo
200200
log.entering(className, methodName, new Object[]{
201201
sendTopics, expectedQosList, sentBytes});
202202

203-
int expectedMessageNumbers[] = new int[nPublishers];
203+
int[] expectedMessageNumbers = new int[nPublishers];
204204
for (int i = 0; i < nPublishers; i++) {
205205
expectedMessageNumbers[i] = 0;
206206
}

org.eclipse.paho.mqttv5.common/src/main/java/org/eclipse/paho/mqttv5/common/packet/MqttDataTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static void writeUnsignedFourByteInt(long value, DataOutputStream stream)
7171
* if an exception occurs whilst reading from the Input Stream
7272
*/
7373
public static Long readUnsignedFourByteInt(DataInputStream inputStream) throws IOException {
74-
byte readBuffer[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
74+
byte[] readBuffer = {0, 0, 0, 0, 0, 0, 0, 0};
7575
inputStream.readFully(readBuffer, 4, 4);
7676
return (((long) readBuffer[0] << 56) + ((long) (readBuffer[1] & 255) << 48)
7777
+ ((long) (readBuffer[2] & 255) << 40) + ((long) (readBuffer[3] & 255) << 32)

0 commit comments

Comments
 (0)