You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2016/10/07 20:03:40 UTC
svn commit: r1763823 - in /tomcat/trunk:
java/org/apache/coyote/http2/ByteUtil.java
test/org/apache/coyote/http2/Http2TestBase.java
test/org/apache/coyote/http2/TestHttp2Section_6_9.java
Author: markt
Date: Fri Oct 7 20:03:39 2016
New Revision: 1763823
URL: http://svn.apache.org/viewvc?rev=1763823&view=rev
Log:
Reduce visibility as recommended by UCdetector
Move utility method only used by tests to test code
Modified:
tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java
tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
Modified: tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java?rev=1763823&r1=1763822&r2=1763823&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/ByteUtil.java Fri Oct 7 20:03:39 2016
@@ -19,25 +19,25 @@ package org.apache.coyote.http2;
/**
* Utility class for extracting values from byte arrays.
*/
-public class ByteUtil {
+class ByteUtil {
private ByteUtil() {
// Hide default constructor
}
- public static boolean isBit7Set(byte input) {
+ static boolean isBit7Set(byte input) {
return (input & 0x80) > 0;
}
- public static int get31Bits(byte[] input, int firstByte) {
+ static int get31Bits(byte[] input, int firstByte) {
return ((input[firstByte] & 0x7F) << 24) + ((input[firstByte + 1] & 0xFF) << 16) +
((input[firstByte + 2] & 0xFF) << 8) + (input[firstByte + 3] & 0xFF);
}
- public static void set31Bits(byte[] output, int firstByte, int value) {
+ static void set31Bits(byte[] output, int firstByte, int value) {
output[firstByte] = (byte) ((value & 0x7F000000) >> 24);
output[firstByte + 1] = (byte) ((value & 0xFF0000) >> 16);
output[firstByte + 2] = (byte) ((value & 0xFF00) >> 8);
@@ -45,47 +45,42 @@ public class ByteUtil {
}
- public static int getOneByte(byte[] input, int pos) {
+ static int getOneByte(byte[] input, int pos) {
return (input[pos] & 0xFF);
}
- public static int getTwoBytes(byte[] input, int firstByte) {
+ static int getTwoBytes(byte[] input, int firstByte) {
return ((input[firstByte] & 0xFF) << 8) + (input[firstByte + 1] & 0xFF);
}
- public static int getThreeBytes(byte[] input, int firstByte) {
+ static int getThreeBytes(byte[] input, int firstByte) {
return ((input[firstByte] & 0xFF) << 16) + ((input[firstByte + 1] & 0xFF) << 8) +
(input[firstByte + 2] & 0xFF);
}
- public static void setOneBytes(byte[] output, int firstByte, int value) {
- output[firstByte] = (byte) (value & 0xFF);
- }
-
-
- public static void setTwoBytes(byte[] output, int firstByte, int value) {
+ static void setTwoBytes(byte[] output, int firstByte, int value) {
output[firstByte] = (byte) ((value & 0xFF00) >> 8);
output[firstByte + 1] = (byte) (value & 0xFF);
}
- public static void setThreeBytes(byte[] output, int firstByte, int value) {
+ static void setThreeBytes(byte[] output, int firstByte, int value) {
output[firstByte] = (byte) ((value & 0xFF0000) >> 16);
output[firstByte + 1] = (byte) ((value & 0xFF00) >> 8);
output[firstByte + 2] = (byte) (value & 0xFF);
}
- public static long getFourBytes(byte[] input, int firstByte) {
+ static long getFourBytes(byte[] input, int firstByte) {
return ((long)(input[firstByte] & 0xFF) << 24) + ((input[firstByte + 1] & 0xFF) << 16) +
((input[firstByte + 2] & 0xFF) << 8) + (input[firstByte + 3] & 0xFF);
}
- public static void setFourBytes(byte[] output, int firstByte, long value) {
+ static void setFourBytes(byte[] output, int firstByte, long value) {
output[firstByte] = (byte) ((value & 0xFF000000) >> 24);
output[firstByte + 1] = (byte) ((value & 0xFF0000) >> 16);
output[firstByte + 2] = (byte) ((value & 0xFF00) >> 8);
Modified: tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java?rev=1763823&r1=1763822&r2=1763823&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/Http2TestBase.java Fri Oct 7 20:03:39 2016
@@ -582,7 +582,7 @@ public abstract class Http2TestBase exte
pingHeader[3] = FrameType.PING.getIdByte();
// Flags
if (ack) {
- ByteUtil.setOneBytes(pingHeader, 4, 0x01);
+ setOneBytes(pingHeader, 4, 0x01);
}
// Stream
ByteUtil.set31Bits(pingHeader, 5, streamId);
@@ -659,7 +659,7 @@ public abstract class Http2TestBase exte
// Payload
ByteUtil.set31Bits(priorityFrame, 9, streamDependencyId);
- ByteUtil.setOneBytes(priorityFrame, 13, weight);
+ setOneBytes(priorityFrame, 13, weight);
os.write(priorityFrame);
os.flush();
@@ -701,6 +701,11 @@ public abstract class Http2TestBase exte
}
+ static void setOneBytes(byte[] output, int firstByte, int value) {
+ output[firstByte] = (byte) (value & 0xFF);
+ }
+
+
private static class TestInput implements Http2Parser.Input {
private final InputStream is;
Modified: tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java?rev=1763823&r1=1763822&r2=1763823&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java (original)
+++ tomcat/trunk/test/org/apache/coyote/http2/TestHttp2Section_6_9.java Fri Oct 7 20:03:39 2016
@@ -81,7 +81,7 @@ public class TestHttp2Section_6_9 extend
byte[] zeroLengthWindowFrame = new byte[9];
// Length zero
- ByteUtil.setOneBytes(zeroLengthWindowFrame, 3, FrameType.WINDOW_UPDATE.getIdByte());
+ setOneBytes(zeroLengthWindowFrame, 3, FrameType.WINDOW_UPDATE.getIdByte());
// No flags
// Stream 1
ByteUtil.set31Bits(zeroLengthWindowFrame, 5, 1);
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org