Skip to content

Commit

Permalink
ph-commons 11.1.5; Java 21 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Mar 27, 2024
1 parent 6b7a99b commit 2fb40cb
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 22 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Note: prior to v9.3.0 the Maven groupId was `com.helger`.

# News and noteworthy

* v10.1.8 - work in progress
* Updated to ph-commons 11.1.5
* Created Java 21 compatibility
* v10.1.7 - 2023-01-07
* Fixed the DNS query type in `NonCachingDnsResolver.createDefaultLookup()` to not use `ANY`
* v10.1.6 - 2024-01-05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
public final class ProxyAutoConfigHelperTest
{
private static final Logger LOGGER = LoggerFactory.getLogger (ProxyAutoConfigHelperTest.class);
private static final String [] PAC_FILES = new String [] { "brz-proxy.pac",
"wikipedia-pac.js",
"returnproxy-complex.js",
"returnproxy-simple-with-loadbalancing.js",
"returnproxy-simple.js",
"ente.regione.emr.it.js",
"example1.js",
"example2.js" };
private static final String [] PAC_FILES = { "brz-proxy.pac",
"wikipedia-pac.js",
"returnproxy-complex.js",
"returnproxy-simple-with-loadbalancing.js",
"returnproxy-simple.js",
"ente.regione.emr.it.js",
"example1.js",
"example2.js" };

@Test
public void testGetProxyListForURL () throws ScriptException
Expand All @@ -78,7 +78,7 @@ private static IProxySettings _getResolved (final String sJS) throws ScriptExcep
{
final String sCode = "function FindProxyForURL(url, host) { " + sJS + " }";
final ProxyAutoConfigHelper aPACHelper = new ProxyAutoConfigHelper (sCode);
return aPACHelper.getProxyListForURL ("any", "host").getFirst ();
return aPACHelper.getProxyListForURL ("any", "host").getFirstOrNull ();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public MockHttpServletRequest addPreferredLocale (@Nonnull final Locale aLocale)
public Locale getLocale ()
{
// One element is added in ctor!
return m_aLocales.getFirst ();
return m_aLocales.getFirstOrNull ();
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public ICommonsSet <String> getHeaderNames ()
public String getHeader (@Nullable final String sName)
{
final ICommonsList <String> aSet = m_aHeaders.getAllHeaderValues (sName);
return aSet == null ? null : aSet.getFirst ();
return aSet == null ? null : aSet.getFirstOrNull ();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public Servlet getServletOfPath (@Nullable final String sPath)
return null;
if (nMatchingItems > 1)
LOGGER.warn ("Found more than 1 servlet matching path '" + sPath + "' - using first one: " + aMatchingItems);
return aMatchingItems.getFirst ().getServlet ();
return aMatchingItems.getFirstOrNull ().getServlet ();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void addURL (@Nonnull final XMLSitemapURL aURL)

protected void removeLastURL ()
{
final XMLSitemapURL aLastURL = m_aURLs.removeLast ();
final XMLSitemapURL aLastURL = m_aURLs.removeLastOrNull ();
m_nOutputLength -= aLastURL.getOutputLength ();

// In case the last URL was the one with the latest modification date, use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String getHeader (@Nonnull final String sName)
final String sNameLower = sName.toLowerCase (Locale.US);

final ICommonsList <String> aHeaderValueList = m_aRWLock.readLockedGet ( () -> m_aHeaderNameToValueListMap.get (sNameLower));
return aHeaderValueList == null ? null : aHeaderValueList.getFirst ();
return aHeaderValueList == null ? null : aHeaderValueList.getFirstOrNull ();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public static EChange handleMultipartFormData (@Nonnull final HttpServletRequest
{
// Convert list of String to value (String or String[])
final ICommonsList <String> aValues = aEntry.getValue ();
final Object aValue = aValues.size () == 1 ? aValues.getFirst () : ArrayHelper.newArray (aValues, String.class);
final Object aValue = aValues.size () == 1 ? aValues.getFirstOrNull ()
: ArrayHelper.newArray (aValues, String.class);
aConsumer.accept (aEntry.getKey (), aValue);
}
// set all form files (potentially overwriting form fields with the same
Expand All @@ -149,8 +150,8 @@ public static EChange handleMultipartFormData (@Nonnull final HttpServletRequest
{
// Convert list of String to value (IFileItem or IFileItem[])
final ICommonsList <IFileItem> aValues = aEntry.getValue ();
final Object aValue = aValues.size () == 1 ? aValues.getFirst () : ArrayHelper.newArray (aValues,
IFileItem.class);
final Object aValue = aValues.size () == 1 ? aValues.getFirstOrNull ()
: ArrayHelper.newArray (aValues, IFileItem.class);
aConsumer.accept (aEntry.getKey (), aValue);
}
// Parsing complex file upload succeeded -> do not use standard scan for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ private ICommonsList <IFileItem> _parseUploadToList (final byte [] bytes) throws

@Nonnull
@ReturnsMutableCopy
private ICommonsList <IFileItem> _parseUploadToList (final InputStream pStream, final int pLength) throws FileUploadException
private ICommonsList <IFileItem> _parseUploadToList (final InputStream pStream,
final int pLength) throws FileUploadException
{
final String contentType = "multipart/form-data; boundary=---1234";

Expand Down Expand Up @@ -260,7 +261,7 @@ private static String _getFooter ()
private static byte [] _newShortRequest () throws IOException
{
try (final NonBlockingByteArrayOutputStream baos = new NonBlockingByteArrayOutputStream ();
final OutputStreamWriter osw = new OutputStreamWriter (baos, StandardCharsets.US_ASCII))
final OutputStreamWriter osw = new OutputStreamWriter (baos, StandardCharsets.US_ASCII))
{
osw.write (_getHeader ("field"));
osw.write ("123");
Expand All @@ -274,7 +275,7 @@ private static String _getFooter ()
private static byte [] _newRequest () throws IOException
{
try (final NonBlockingByteArrayOutputStream baos = new NonBlockingByteArrayOutputStream ();
final OutputStreamWriter osw = new OutputStreamWriter (baos, StandardCharsets.US_ASCII))
final OutputStreamWriter osw = new OutputStreamWriter (baos, StandardCharsets.US_ASCII))
{
int nAdd = 16;
int nNum = 0;
Expand Down Expand Up @@ -350,7 +351,7 @@ public void testInvalidFileNameException () throws Exception
assertEquals ("foo.exe", fileItemStream.getNameSecure ());

final ICommonsList <IFileItem> fileItems = _parseUploadToList (aReqBytes);
final IFileItem fileItem = fileItems.getFirst ();
final IFileItem fileItem = fileItems.getFirstOrNull ();
try
{
fileItem.getName ();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<dependency>
<groupId>com.helger.commons</groupId>
<artifactId>ph-commons-parent-pom</artifactId>
<version>11.1.4</version>
<version>11.1.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down

0 comments on commit 2fb40cb

Please sign in to comment.