This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new ae9a764a64 Checkstyle
ae9a764a64 is described below
commit ae9a764a64a2af8ceae6f85ac5be9eebfa63479b
Author: remm <[email protected]>
AuthorDate: Thu May 21 19:53:34 2026 +0200
Checkstyle
---
java/org/apache/juli/DateFormatCache.java | 2 +
test/org/apache/juli/TestDateFormatCache.java | 59 +++++++--------------------
2 files changed, 17 insertions(+), 44 deletions(-)
diff --git a/java/org/apache/juli/DateFormatCache.java
b/java/org/apache/juli/DateFormatCache.java
index e40e8e3550..822c1dd1fe 100644
--- a/java/org/apache/juli/DateFormatCache.java
+++ b/java/org/apache/juli/DateFormatCache.java
@@ -62,6 +62,8 @@ public class DateFormatCache {
* Replace the millisecond formatting character 'S' by some dummy
characters in order to make the resulting
* formatted time stamps cacheable. Our consumer might choose to replace
the dummy chars with the actual
* milliseconds because that's relatively cheap.
+ * @param format the format
+ * @return the replacement format
*/
protected static String tidyFormat(String format) {
final int length = format.length();
diff --git a/test/org/apache/juli/TestDateFormatCache.java
b/test/org/apache/juli/TestDateFormatCache.java
index 46a6e3a898..f252b37627 100644
--- a/test/org/apache/juli/TestDateFormatCache.java
+++ b/test/org/apache/juli/TestDateFormatCache.java
@@ -57,40 +57,34 @@ public class TestDateFormatCache {
dfc.getFormat(secs * 1000);
expected[secs] = generateExpected(sdf, secs);
}
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
// Cause the cache to roll-around by one and then confirm
dfc.getFormat(cacheSize * 1000);
expected[0] = generateExpected(sdf, cacheSize);
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
// Jump 2 ahead and then confirm (skipped value should be null)
dfc.getFormat((cacheSize + 2) * 1000);
expected[1] = null;
expected[2] = generateExpected(sdf, cacheSize + 2);
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
// Back 1 to fill in the gap
dfc.getFormat((cacheSize + 1) * 1000);
expected[1] = generateExpected(sdf, cacheSize + 1);
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
// Return to 1 and confirm skipped value is null
dfc.getFormat(1 * 1000);
expected[1] = generateExpected(sdf, 1);
expected[2] = null;
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
// Go back one further
dfc.getFormat(0);
expected[0] = generateExpected(sdf, 0);
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
// Jump ahead far enough that the entire cache will need to be cleared
dfc.getFormat(42 * 1000);
@@ -98,8 +92,7 @@ public class TestDateFormatCache {
expected[i] = null;
}
expected[0] = generateExpected(sdf, 42);
- Assert.assertArrayEquals(expected,
- (String[]) dfcCacheArray.get(dfcCache));
+ Assert.assertArrayEquals(expected, (String[])
dfcCacheArray.get(dfcCache));
}
private String generateExpected(SimpleDateFormat sdf, long secs) {
@@ -108,59 +101,37 @@ public class TestDateFormatCache {
@Test
public void replacesUnquotedS() {
- Assert.assertEquals(
- "HH:mm:ss.###",
- DateFormatCache.tidyFormat("HH:mm:ss.SSS")
- );
+ Assert.assertEquals("HH:mm:ss.###",
DateFormatCache.tidyFormat("HH:mm:ss.SSS"));
}
@Test
public void doesNotReplaceQuotedS() {
- Assert.assertEquals(
- "HH:mm:ss.'SSS'",
- DateFormatCache.tidyFormat("HH:mm:ss.'SSS'")
- );
+ Assert.assertEquals("HH:mm:ss.'SSS'",
DateFormatCache.tidyFormat("HH:mm:ss.'SSS'"));
}
@Test
public void handlesEscapedQuoteInsideLiteral() {
- Assert.assertEquals(
- "'o''clock' ###",
- DateFormatCache.tidyFormat("'o''clock' SSS")
- );
+ Assert.assertEquals("'o''clock' ###",
DateFormatCache.tidyFormat("'o''clock' SSS"));
}
@Test
public void doesNotReplaceSInsideLiteralAfterEscapedQuote() {
- Assert.assertEquals(
- "'abc''SSS'",
- DateFormatCache.tidyFormat("'abc''SSS'")
- );
+ Assert.assertEquals("'abc''SSS'",
DateFormatCache.tidyFormat("'abc''SSS'"));
}
@Test
public void handlesMultipleLiteralSections() {
- Assert.assertEquals(
- "'foo' ### 'bar'",
- DateFormatCache.tidyFormat("'foo' SSS 'bar'")
- );
+ Assert.assertEquals("'foo' ### 'bar'",
DateFormatCache.tidyFormat("'foo' SSS 'bar'"));
}
@Test
public void handlesEscapedQuoteOutsideLiteral() {
- Assert.assertEquals(
- "'' ###",
- DateFormatCache.tidyFormat("'' SSS")
- );
+ Assert.assertEquals("'' ###", DateFormatCache.tidyFormat("'' SSS"));
}
@Test
public void complexQuoteScenario() {
- Assert.assertEquals(
- "'Start' ### 'o''clock' ### '' 'End'",
- DateFormatCache.tidyFormat(
- "'Start' SSS 'o''clock' SSS '' 'End'"
- )
- );
+ Assert.assertEquals("'Start' ### 'o''clock' ### '' 'End'",
+ DateFormatCache.tidyFormat("'Start' SSS 'o''clock' SSS ''
'End'"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]