Skip to content

Commit

Permalink
Merge pull request #415 from apache/refactoring/409-Update-dependencies
Browse files Browse the repository at this point in the history
Issue #409: Update dependencies
  • Loading branch information
reckart authored Nov 18, 2024
2 parents 146d723 + 6b65735 commit d2a5847
Show file tree
Hide file tree
Showing 22 changed files with 281 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: echo "CACHE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Build with Maven
run: mvn --no-transfer-progress -B clean verify --file pom.xml
run: mvn --no-transfer-progress -B -DskipTests clean verify --file pom.xml

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class BaseServerRunnable implements Runnable {

private BaseServer parent;

private static final ThreadLocal THREAD_LOCAL_SOCKET = new ThreadLocal();
private static final ThreadLocal<Socket> THREAD_LOCAL_SOCKET = new ThreadLocal<>();

/**
* Allows anyone in the calling chain of the 'run' method to get access to the socket being used
Expand All @@ -46,7 +46,7 @@ public class BaseServerRunnable implements Runnable {
* @return -
*/
public static Socket getSocket() {
return (Socket) THREAD_LOCAL_SOCKET.get();
return THREAD_LOCAL_SOCKET.get();
}

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ public void run() {
} catch (Throwable e) {
Debug.reportException(e);
} finally {
THREAD_LOCAL_SOCKET.set(null);
THREAD_LOCAL_SOCKET.remove();
try {
socket.close();
} catch (IOException f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ public class XTalkTransporter implements FrameTransporter {
public KeyValuePair fromStream(InputStream is, Frame f) throws IOException, EOFException {
char[] cbuffer = new char[128];
byte[] buffer = new byte[128];
int marker = is.read();
if (marker == -1) {
throw new EOFException();
}
var marker = readByte(is);

if ((byte) marker != DOCUMENT_MARKER) {
throw new IOException("Expected document marker: " + (char) marker);
}

return fromStreamWork(is, f, buffer, cbuffer);
}

Expand All @@ -93,15 +92,15 @@ public KeyValuePair fromStreamWork(InputStream is, Frame f) throws IOException {

public KeyValuePair fromStreamWork(InputStream is, Frame f, byte[] buffer, char[] cbuffer)
throws IOException {
int version = is.read();
if ((byte) version != VERSION_CODE) {
var version = readByte(is);
if (version != VERSION_CODE) {
throw new IOException(
"Xtalk version code doesn't match " + (int) VERSION_CODE + ": " + version);
}
int top_field_count = readInt(is);
// Skip over intro PI's.
int marker;
while ((marker = is.read()) == PI_MARKER) {
byte marker;
while ((marker = readByte(is)) == PI_MARKER) {
ignorePI(is);
top_field_count--;
}
Expand All @@ -112,7 +111,7 @@ public KeyValuePair fromStreamWork(InputStream is, Frame f, byte[] buffer, char[
top_field_count--;
// Skip over trailing PI's
while (top_field_count > 0) {
marker = is.read();
marker = readByte(is);
if ((byte) marker != 'p') {
throw new IOException("Expected pi marker: " + (char) marker);
}
Expand Down Expand Up @@ -187,12 +186,12 @@ public KeyValuePair consumeRootChildren(InputStream is, Frame f, byte[] buffer,
int field_count = readInt(is);
KeyValuePair return_me = null;
if (field_count != 0) {
int marker = is.read();
var marker = readByte(is);
if ((byte) marker == ELEMENT_MARKER) {
return_me = consumeRootElement(is, f, buffer, cbuffer);
field_count--;
if (field_count > 0) {
marker = is.read();
marker = readByte(is);
} else {
return return_me;
}
Expand Down Expand Up @@ -238,7 +237,7 @@ public KeyValuePair consumeRootElement(InputStream is, Frame f, byte[] buffer, c
// it is of a different type.
}
} else {
int sub_marker = is.read();
var sub_marker = readByte(is);
if (sub_field_count == 1 && (byte) sub_marker == STRING_MARKER) {
value = consumeLeaf(is, f);
if (tag_name.startsWith(TransportConstants.VINCI_NAMESPACE)) {
Expand Down Expand Up @@ -301,7 +300,7 @@ public void consumeChildren(InputStream is, Frame f, int field_count, int marker
if (sub_field_count == 0) {
value = f.createSubFrame(tag_name, sub_field_count);
} else {
int sub_marker = is.read();
var sub_marker = readByte(is);
if (sub_field_count == 1 && (byte) sub_marker == STRING_MARKER) {
value = consumeLeaf(is, f);
} else {
Expand All @@ -319,7 +318,7 @@ public void consumeChildren(InputStream is, Frame f, int field_count, int marker
}
field_count--;
if (field_count > 0) {
marker = is.read();
marker = readByte(is);
}
}
}
Expand Down Expand Up @@ -671,4 +670,17 @@ public void attributesToBin(OutputStream os, Attributes attributes, byte[] workb
}
}

} // class
private static byte readByte(InputStream aIs) throws IOException {
int byteAsInt = aIs.read();

if (byteAsInt == -1) {
throw new EOFException("Unexpected end of stream");
}

if (byteAsInt < Byte.MIN_VALUE || byteAsInt > Byte.MAX_VALUE) {
throw new IOException("Illegal byte value [" + byteAsInt + "]");
}

return (byte) byteAsInt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void resizeBuffers(int toSize) {
* the document. Use bufferSize() and resizeBuffers to manage memory in applications where very
* large strings may be encountered and the same object is used to parse many incoming documents.
*
* @param is
* @param aIs
* -
* @param handler
* -
Expand All @@ -108,19 +108,17 @@ public void resizeBuffers(int toSize) {
* @pre handler != null
* @pre is != null
*/
public void parse(InputStream is, ContentHandler handler) throws IOException, SAXException {
this.is = is;
public void parse(InputStream aIs, ContentHandler handler) throws IOException, SAXException {
this.is = aIs;
this.handler = handler;
try {
int marker = is.read();
if (marker == -1) {
throw new EOFException();
}
var marker = readByte(aIs);

if ((byte) marker != XTalkTransporter.DOCUMENT_MARKER) {
throw new IOException("Expected document marker: " + (char) marker);
}
int version = is.read();
if ((byte) version != XTalkTransporter.VERSION_CODE) {
var version = readByte(aIs);
if (version != XTalkTransporter.VERSION_CODE) {
throw new IOException("Xtalk version code doesn't match "
+ (int) XTalkTransporter.VERSION_CODE + ": " + version);
}
Expand All @@ -129,19 +127,20 @@ public void parse(InputStream is, ContentHandler handler) throws IOException, SA
handler.endDocument();
} finally {
// nullify refs to allow GC
is = null;
aIs = null;
handler = null;
}
}

private void doTopLevelParse() throws IOException, SAXException {
int top_field_count = XTalkTransporter.readInt(is);
// Skip over intro PI's.
int marker;
byte marker;
if (top_field_count < 1) {
throw new IOException("No top level element.");
}
while ((marker = is.read()) == XTalkTransporter.PI_MARKER) {

while ((marker = readByte(is)) == XTalkTransporter.PI_MARKER) {
String target = consumeString();
String data = consumeString();
handler.processingInstruction(target, data);
Expand All @@ -157,7 +156,7 @@ private void doTopLevelParse() throws IOException, SAXException {
top_field_count--;
// Handle trailing PI's
while (top_field_count > 0) {
if (is.read() != XTalkTransporter.PI_MARKER) {
if (readByte(is) != XTalkTransporter.PI_MARKER) {
throw new IOException("Expected PI marker.");
}
doProcessingInstruction();
Expand Down Expand Up @@ -198,8 +197,8 @@ private void doElement() throws IOException, SAXException {
handler.startElement("", tagName, tagName, workAttributes);
int field_count = XTalkTransporter.readInt(is);
for (int i = 0; i < field_count; i++) {
int marker = is.read();
switch ((byte) marker) {
var marker = readByte(is);
switch (marker) {
case XTalkTransporter.PI_MARKER:
doProcessingInstruction();
break;
Expand All @@ -220,4 +219,17 @@ private void doElement() throws IOException, SAXException {
handler.endElement(null, null, tagName);
}

private static byte readByte(InputStream aIs) throws IOException {
int byteAsInt = aIs.read();

if (byteAsInt == -1) {
throw new EOFException("Unexpected end of stream");
}

if (byteAsInt < Byte.MIN_VALUE || byteAsInt > Byte.MAX_VALUE) {
throw new IOException("Illegal byte value [" + byteAsInt + "]");
}

return (byte) byteAsInt;
}
}
22 changes: 17 additions & 5 deletions uimafit-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<groupId>com.github.h-thurow</groupId>
<artifactId>simple-jndi</artifactId>
<version>0.24.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -172,7 +173,8 @@
<configuration>
<excludes combine.children="append">
<!-- These test files are unreasonable to bear a license header -->
<exclude>src/test/resources/log4j.properties</exclude>
<exclude>src/test/resources/jndi.properties</exclude>
<exclude>src/test/resources/jndi/DO-NOT-DELETE</exclude>
<!-- Plain documentation -->
<exclude>README*</exclude>
<!-- Release files -->
Expand Down Expand Up @@ -204,6 +206,16 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoredDependencies combine.children="append">
<!-- Used via reflection -->
<ignoredDependency>com.github.h-thurow:simple-jndi</ignoredDependency>
</ignoredDependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@

/**
* Locate an object via JNDI.
*
* @deprecated To be removed without replacement
* @forRemoval 4.0.0
*/
@Deprecated
public class JndiResourceLocator extends Resource_ImplBase implements ExternalResourceLocator {
/**
* The name of the JNDI resource to look up.
Expand Down Expand Up @@ -60,6 +64,7 @@ public boolean initialize(ResourceSpecifier aSpecifier, Map aAdditionalParams)
return true;
}

@Override
public Object getResource() {
return resource;
}
Expand Down
Loading

0 comments on commit d2a5847

Please sign in to comment.