diff --git a/.circleci/config.yml b/.circleci/config.yml
index 65723f0..f0fb009 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -1,41 +1,42 @@
-inversion: 2
-defaults: &defaults
- working_directory: ~/repo
- environment:
- JVM_OPTS: -Xmx3200m
- TERM: dumb
- CI_NAME: "CircleCI"
-
-defaults_gradle: &defaults_bld
- steps:
- - checkout
- - run:
- name: Download the dependencies
- command: ./bld download
- - run:
- name: Run tests with bld
- command: ./bld compile test
+version: 2.1
+commands:
+ build_and_test:
+ parameters:
+ reports-dir:
+ type: string
+ default: "build/reports/test_results"
+ steps:
+ - checkout
+ - run:
+ name: Download dependencies
+ command: ./bld download
+ - run:
+ name: Compile source
+ command: ./bld compile
+ - run:
+ name: Run tests
+ command: ./bld jacoco -reports-dir=<< parameters.reports-dir >>
+ - store_test_results:
+ path: << parameters.reports-dir >>
+ - store_artifacts:
+ path: build/reports/jacoco/test/html
jobs:
- bld_jdk20:
- <<: *defaults
-
- docker:
- - image: cimg/openjdk:20.0
-
- <<: *defaults_bld
-
bld_jdk17:
- <<: *defaults
-
docker:
- image: cimg/openjdk:17.0
+ steps:
+ - build_and_test
- <<: *defaults_bld
+ bld_jdk21:
+ docker:
+ - image: cimg/openjdk:21.0
+ steps:
+ - build_and_test
workflows:
- version: 2
bld:
jobs:
- bld_jdk17
- - bld_jdk20
+ - bld_jdk21
+
diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml
index 79093d1..057289d 100644
--- a/.github/workflows/bld.yml
+++ b/.github/workflows/bld.yml
@@ -4,50 +4,50 @@ on: [ push, pull_request, workflow_dispatch ]
jobs:
build-bld-project:
- runs-on: ubuntu-latest
-
env:
- COVERAGE_SDK: "17"
+ COVERAGE_JDK: "17"
strategy:
matrix:
- java-version: [ 17, 20 ]
+ java-version: [ 17, 21, 24 ]
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
+
+ runs-on: ${{ matrix.os }}
steps:
- name: Checkout source repository
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java-version }}
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
- distribution: 'zulu'
+ distribution: "zulu"
java-version: ${{ matrix.java-version }}
- - name: Grant execute permission for bld
- run: chmod +x bld
-
- - name: Download the dependencies
+ - name: Download dependencies
run: ./bld download
- - name: Run tests with bld
- run: ./bld compile jacoco
+ - name: Compile source
+ run: ./bld compile
+
+ - name: Run tests
+ run: ./bld jacoco
- name: Remove pom.xml
- if: success() && matrix.java-version == env.COVERAGE_SDK
+ if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.os == 'ubuntu-latest'
run: rm -rf pom.xml
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
- if: success() && matrix.java-version == env.COVERAGE_SDK
+ if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.os == 'ubuntu-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- if: success() && matrix.java-version == env.COVERAGE_SDK
+ if: success() && matrix.java-version == env.COVERAGE_JDK && matrix.os == 'ubuntu-latest'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
-
diff --git a/.github_changelog_generator b/.github_changelog_generator
index 19e45d2..9410c34 100644
--- a/.github_changelog_generator
+++ b/.github_changelog_generator
@@ -1 +1 @@
-future-release=1.1.0
+future-release=1.1.2
diff --git a/.idea/bld.xml b/.idea/bld.xml
new file mode 100644
index 0000000..6600cee
--- /dev/null
+++ b/.idea/bld.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml
index 722b42e..153a060 100644
--- a/.idea/libraries/bld.xml
+++ b/.idea/libraries/bld.xml
@@ -2,11 +2,12 @@
-
+
-
+
+
@@ -14,4 +15,4 @@
-
\ No newline at end of file
+
diff --git a/.idea/libraries/compile.xml b/.idea/libraries/compile.xml
index 9bd86aa..99cc0c0 100644
--- a/.idea/libraries/compile.xml
+++ b/.idea/libraries/compile.xml
@@ -7,7 +7,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/runtime.xml b/.idea/libraries/runtime.xml
index 2ae5c4b..d4069f2 100644
--- a/.idea/libraries/runtime.xml
+++ b/.idea/libraries/runtime.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/test.xml b/.idea/libraries/test.xml
index b80486a..57ed5ef 100644
--- a/.idea/libraries/test.xml
+++ b/.idea/libraries/test.xml
@@ -8,7 +8,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 9963c9f..71f1817 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,15 +1,20 @@
-
+
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 2dd24a5..32bf99b 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,11 +1,11 @@
{
- "version": "0.2.0",
- "configurations": [
- {
- "type": "java",
- "name": "Run Tests",
- "request": "launch",
- "mainClass": "net.thauvin.erik.httpstatus.HttpStatusTest"
- }
- ]
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "Run Tests",
+ "request": "launch",
+ "mainClass": "net.thauvin.erik.httpstatus.HttpStatusTest"
+ }
+ ]
}
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 5ae2eaa..3ef096f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,13 +3,12 @@
"src/main/java",
"src/main/resources",
"src/test/java",
- "src/bld/java"
+ "src/bld/java",
+ "src/bld/resources"
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
- "${HOME}bld-1.7.0.jar",
- "lib/compile/*.jar",
- "lib/runtime/*.jar",
- "lib/test/*.jar"
+ "${HOME}/.bld/dist/bld-2.2.1.jar",
+ "lib/**/*.jar",
]
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a090c2..159135a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog
+## [1.1.1](https://github.com/ethauvin/httpstatus/tree/1.1.1) (2024-06-07)
+
+[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.1.0...1.1.1)
+
+**Implemented enhancements:**
+
+- Sort command line output [\#10](https://github.com/ethauvin/HttpStatus/issues/10)
+- Update reasons properties status codes [\#9](https://github.com/ethauvin/HttpStatus/issues/9)
+
## [1.1.0](https://github.com/ethauvin/httpstatus/tree/1.1.0) (2023-09-29)
[Full Changelog](https://github.com/ethauvin/httpstatus/compare/1.0.5...1.1.0)
diff --git a/LICENSE.txt b/LICENSE.txt
index 3f79a9e..79de5a8 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2015-2023, Erik C. Thauvin (erik@thauvin.net)
+Copyright (c) 2015-2025, Erik C. Thauvin (erik@thauvin.net)
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/README.md b/README.md
index 4b6545c..40bc87c 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
[](http://opensource.org/licenses/BSD-3-Clause)
[](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
-[](https://rife2.com/bld)
+[](https://rife2.com/bld)
[](https://github.com/ethauvin/httpstatus/releases/latest)
-[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/httpstatus/httpstatus/)
+[](https://oss.sonatype.org/content/repositories/snapshots/net/thauvin/erik/httpstatus/httpstatus/)
[](https://central.sonatype.com/artifact/net.thauvin.erik.httpstatus/httpstatus)
[](https://snyk.io/test/github/ethauvin/httpstatus?targetFile=pom.xml)
@@ -17,11 +17,11 @@ A simple [JSP](http://www.oracle.com/technetwork/java/javaee/jsp/index.html) Tag
## Table of Contents
- [Examples](#examples)
-- Usage
+- [Usage](#usage)
- [Gradle](#gradle)
- [bld](#bld)
- [Maven](#maven)
-- JSP Tags
+- [JSP Tags](#jsp-tags)
- [hs:cause](#hscause)
- [hs:code](#hscode)
- [hs:message](#hsmessage)
@@ -29,6 +29,7 @@ A simple [JSP](http://www.oracle.com/technetwork/java/javaee/jsp/index.html) Tag
- [StatusCode Bean](#statuscode-bean)
- [Reasons](#reasons)
- [Command Line Usage](#command-line-usage)
+- [Contributing](#contributing)
## Examples
@@ -55,7 +56,7 @@ or
would display on a [501 status code](https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented):
-```plain
+```console
Not Implemented
```
@@ -71,7 +72,7 @@ repositories {
}
dependencies {
- implementation 'net.thauvin.erik.httpstatus:httpstatus:1.1.0'
+ implementation 'net.thauvin.erik.httpstatus:httpstatus:1.1.1'
}
```
@@ -93,7 +94,7 @@ As a `Maven` artifact:
net.thauvin.erik.httpstatus
httpstatus
- 1.1.0
+ 1.1.1
```
@@ -110,7 +111,7 @@ The `` tag displays the cause of current HTTP status code, if any. A
Optional attributes are:
| Attribute | Description |
-|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
+| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `default` | The fallback value to output, if no cause is |
| `escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. |
@@ -133,7 +134,7 @@ The `` tag displays the current error message, if any. A shorthand
Optional attributes are:
| Attribute | Description |
-|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
+| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `default` | The fallback value to output, if no error message is available. |
| `escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. |
@@ -142,7 +143,7 @@ Optional attributes are:
The `` tag displays the reason for an HTTP status code, if any. Optional attributes are:
| Attribute | Description |
-|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
+| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `default` | The fallback value to output, if no reason is available. |
| `code` | The HTTP status error code. If not specified the current status code is used. |
| `escapeXml` | Converts <, >, &, ', " to their corresponding [entity codes](http://dev.w3.org/html5/html-author/charref). Value is `true` by default. |
@@ -190,7 +191,7 @@ public class ExampleServlet extends HttpServlet {
The `StatusCode` bean methods are:
| Method | Description |
-|-----------------|----------------------------------------------------------------------|
+| --------------- | -------------------------------------------------------------------- |
| `getReason` | Returns the reason for the status code (eg: `Internal Server Error`) |
| `isClientError` | Checks if the status code is a client error. |
| `isError` | Checks if the status code is a server or client error. |
@@ -205,11 +206,16 @@ The `StatusCode` bean methods are:
The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ResourceBundle.html) properties as follows:
| Status Code | Reason |
-|-------------|------------------------------------------------------------|
+| ----------- | ---------------------------------------------------------- |
| `100` | Continue |
| `101` | Switching Protocols |
| `102` | Processing |
| `103` | Early Hints |
+| `110` | Response is Stale |
+| `111` | Revalidation Failed |
+| `112` | Disconnected Operation |
+| `113` | Heuristic Expiration |
+| `199` | Miscellaneous Warning |
| `200` | OK |
| `201` | Created |
| `202` | Accepted |
@@ -219,15 +225,17 @@ The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/ja
| `206` | Partial Content |
| `207` | Multi-Status |
| `208` | Already Reported |
+| `214` | Transformation Applied |
| `218` | This is fine |
| `226` | IM Used |
+| `299` | Miscellaneous Persistent Warning |
| `300` | Multiple Choices |
| `301` | Moved Permanently |
| `302` | Found/Moved Temporarily |
| `303` | See Other |
| `304` | Not Modified |
| `305` | Use Proxy |
-| `306` | Switch Proxy |
+| `306` | Unused |
| `307` | Temporary Redirect |
| `308` | Permanent Redirect |
| `400` | Bad Request |
@@ -243,18 +251,19 @@ The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/ja
| `410` | Gone |
| `411` | Length Required |
| `412` | Precondition Failed |
-| `413` | Request Entity/Payload Too Large |
-| `414` | Request-URI Too Long |
+| `413` | Payload Too Large |
+| `414` | URI Too Long |
| `415` | Unsupported Media Type |
-| `416` | Requested Range Not Satisfiable |
+| `416` | Range Not Satisfiable |
| `417` | Expectation Failed |
| `418` | I'm A Teapot |
| `419` | Insufficient Space on Resource |
| `420` | Method Failure |
| `421` | Misdirected Request |
-| `422` | Unprocessable Entity |
+| `422` | Unprocessable Content |
| `423` | Locked |
| `424` | Failed Dependency |
+| `425` | Too Early |
| `426` | Upgrade Required |
| `428` | Precondition Required |
| `429` | Too Many Requests |
@@ -269,7 +278,7 @@ The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/ja
| `463` | X-Forwarded-For Header with More than 30 IP Addresses |
| `494` | Request Header Too Large |
| `495` | SSL Certificate Error |
-| `496` | No SSL Certificate |
+| `496` | SSL Certificate Required |
| `497` | HTTP Request Sent to HTTPS Port |
| `498` | Token Expired/Invalid |
| `499` | Client Closed Request |
@@ -287,7 +296,7 @@ The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/ja
| `511` | Network Authentication Required |
| `520` | Unknown Error |
| `521` | Web Server Is Down |
-| `522` | Origin Connection Time-out |
+| `522` | Connection Timed Out |
| `523` | Origin Is Unreachable |
| `524` | A Timeout Occurred |
| `525` | SSL Handshake Failed |
@@ -295,27 +304,35 @@ The reasons are defined in a [ResourceBundle](https://docs.oracle.com/en/java/ja
| `527` | Railgun Error |
| `529` | Site is overloaded |
| `530` | Site is frozen |
+| `540` | Temporarily Disabled |
+| `561` | Unauthorized |
| `598` | Network Read Timeout Error |
| `599` | Network Connect Timeout Error |
+| `783` | Unexpected Token |
## Command Line Usage
You can query the reason phrase for status codes as follows:
-```sh
-$ java -jar httpstatus-1.1.0.jar 404 500
+```console
+$ java -jar httpstatus-1.1.1.jar 404 500
404: Not Found
500: Internal Server Error
```
If no status code is specified, all will be printed:
-```sh
-$ java -jar httpstatus-1.1.0.jar
+```console
+$ java -jar httpstatus-1.1.1.jar
100: Continue
101: Switching Protocols
102: Processing
103: Early Hints
+110: Response is Stale
+111: Revalidation Failed
+112: Disconnected Operation
+113: Heuristic Expiration
+199: Miscellaneous Warning
200: OK
201: Created
202: Accepted
@@ -325,11 +342,30 @@ $ java -jar httpstatus-1.1.0.jar
You can also print status codes by [response classes](https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes):
-```sh
-$ java -jar httpstatus-1.1.0.jar 2xx
+```console
+$ java -jar httpstatus-1.1.1.jar 2xx
200: OK
201: Created
202: Accepted
203: Non-Authoritative Information
-
+...
```
+
+## Contributing
+
+If you want to contribute to this project, all you have to do is clone the GitHub
+repository:
+
+```console
+git clone git@github.com:ethauvin/HttpStatus.git
+```
+
+Then use [bld](https://rife2.com/bld) to build:
+
+```console
+cd HttpStatus
+./bld compile
+```
+
+The project has an [IntelliJ IDEA](https://www.jetbrains.com/idea/) project structure. You can just open it after all
+the dependencies were downloaded and peruse the code.
diff --git a/config/pmd.xml b/config/pmd.xml
index 1039e40..2641880 100644
--- a/config/pmd.xml
+++ b/config/pmd.xml
@@ -7,9 +7,9 @@
-
-
+
+
@@ -24,8 +24,8 @@
-
+
@@ -35,8 +35,9 @@
-
+
+
@@ -52,8 +53,6 @@
-
-
@@ -107,4 +106,4 @@
-
\ No newline at end of file
+
diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar
index 605e3e4..7d0825c 100644
Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ
diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties
index 6ee7345..418f275 100644
--- a/lib/bld/bld-wrapper.properties
+++ b/lib/bld/bld-wrapper.properties
@@ -1,7 +1,7 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
-bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.2
-bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1-SNAPSHOT
-bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL
bld.downloadLocation=
-bld.version=1.7.2
+bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
+bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.3
+bld.repositories=MAVEN_CENTRAL,RIFE2_RELEASES,MAVEN_LOCAL,RIFE2_SNAPSHOTS
+bld.version=2.2.1
diff --git a/pom.xml b/pom.xml
index cc15182..73cf087 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,33 +4,33 @@
4.0.0
net.thauvin.erik.httpstatus
httpstatus
- 1.1.0
+ 1.1.2-SNAPSHOT
HttpStatus
Tag library to display the code, reason, cause and/or message for HTTP status codes in JSP error pages
https://github.com/ethauvin/HttpStatus
The BSD 3-Clause License
- http://opensource.org/licenses/BSD-3-Clause
+ https://opensource.org/licenses/BSD-3-Clause
jakarta.servlet
jakarta.servlet-api
- 6.0.0
+ 6.1.0
compile
jakarta.servlet.jsp
jakarta.servlet.jsp-api
- 3.1.1
+ 4.0.0
compile
jakarta.el
jakarta.el-api
- 5.0.1
+ 6.0.1
compile
diff --git a/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java b/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java
index 9547222..9c36ca8 100644
--- a/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java
+++ b/src/bld/java/net/thauvin/erik/httpstatus/HttpStatusBuild.java
@@ -1,7 +1,7 @@
/*
* HttpStatusBuild.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -39,8 +39,7 @@ import rife.bld.extension.PmdOperation;
import rife.bld.publish.*;
import rife.tools.exceptions.FileUtilsErrorException;
-import java.io.IOException;
-import java.nio.file.Path;
+import java.io.File;
import java.util.List;
import java.util.jar.Attributes;
@@ -50,10 +49,15 @@ import static rife.bld.dependencies.Scope.test;
import static rife.bld.operations.JavadocOptions.DocLinkOption.NO_MISSING;
public class HttpStatusBuild extends Project {
+ final PmdOperation pmdOp = new PmdOperation()
+ .fromProject(this)
+ .failOnViolation(true)
+ .ruleSets("config/pmd.xml");
+
public HttpStatusBuild() {
pkg = "net.thauvin.erik.httpstatus";
name = "HttpStatus";
- version = version(1, 1, 0);
+ version = version(1, 1, 2, "SNAPSHOT");
var description = "Tag library to display the code, reason, cause and/or message for HTTP status codes in JSP error pages";
var url = "https://github.com/ethauvin/HttpStatus";
@@ -63,16 +67,17 @@ public class HttpStatusBuild extends Project {
javaRelease = 17;
downloadSources = true;
+ autoDownloadPurge = true;
repositories = List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS);
scope(compile)
- .include(dependency("jakarta.servlet", "jakarta.servlet-api", version(6, 0, 0)))
- .include(dependency("jakarta.servlet.jsp", "jakarta.servlet.jsp-api", version(3, 1, 1)))
- .include(dependency("jakarta.el", "jakarta.el-api", version(5, 0, 1)));
+ .include(dependency("jakarta.servlet", "jakarta.servlet-api", version(6, 1, 0)))
+ .include(dependency("jakarta.servlet.jsp", "jakarta.servlet.jsp-api", version(4, 0, 0)))
+ .include(dependency("jakarta.el", "jakarta.el-api", version(6, 0, 1)));
scope(test)
- .include(dependency("org.assertj", "assertj-core", version(3, 24, 2)))
- .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0)))
- .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 0)));
+ .include(dependency("org.assertj", "assertj-core", version(3, 27, 3)))
+ .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 2)))
+ .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 2)));
jarOperation().manifestAttribute(Attributes.Name.MAIN_CLASS, pkg + '.' + "Reasons");
@@ -84,8 +89,9 @@ public class HttpStatusBuild extends Project {
publishOperation()
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
.withCredentials(property("sonatype.user"), property("sonatype.password"))
- : repository("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
+ : repository(SONATYPE_RELEASES_LEGACY.location())
.withCredentials(property("sonatype.user"), property("sonatype.password")))
+ .repository(repository("github"))
.info(new PublishInfo()
.groupId(pkg)
.artifactId(name.toLowerCase())
@@ -93,11 +99,18 @@ public class HttpStatusBuild extends Project {
.version(version)
.description(description)
.url(url)
- .developer(new PublishDeveloper().id("ethauvin").name("Erik C. Thauvin").email("erik@thauvin.net")
- .url("https://erik.thauvin.net/"))
- .license(new PublishLicense().name("The BSD 3-Clause License")
- .url("http://opensource.org/licenses/BSD-3-Clause"))
- .scm(new PublishScm().connection("scm:git:" + url + ".git")
+ .developer(new PublishDeveloper()
+ .id("ethauvin")
+ .name("Erik C. Thauvin")
+ .email("erik@thauvin.net")
+ .url("https://erik.thauvin.net/")
+ )
+ .license(new PublishLicense()
+ .name("The BSD 3-Clause License")
+ .url("https://opensource.org/licenses/BSD-3-Clause")
+ )
+ .scm(new PublishScm()
+ .connection("scm:git:" + url + ".git")
.developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
.url(url))
.signKey(property("sign.key"))
@@ -109,35 +122,36 @@ public class HttpStatusBuild extends Project {
}
@BuildCommand(summary = "Generates JaCoCo Reports")
- public void jacoco() throws IOException {
+ public void jacoco() throws Exception {
new JacocoReportOperation()
.fromProject(this)
.execute();
}
@BuildCommand(summary = "Runs PMD analysis")
- public void pmd() {
- new PmdOperation()
- .fromProject(this)
- .failOnViolation(true)
- .ruleSets("config/pmd.xml")
- .execute();
+ public void pmd() throws Exception {
+ pmdOp.execute();
+ }
+
+ @BuildCommand(value = "pmd-cli", summary = "Runs PMD analysis (CLI)")
+ public void pmdCli() throws Exception {
+ pmdOp.includeLineNumber(false).execute();
+ }
+
+ private void pomRoot() throws FileUtilsErrorException {
+ PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
+ new File(workDirectory, "pom.xml"));
}
@Override
public void publish() throws Exception {
super.publish();
- rootPom();
+ pomRoot();
}
@Override
public void publishLocal() throws Exception {
super.publishLocal();
- rootPom();
- }
-
- private void rootPom() throws FileUtilsErrorException {
- PomBuilder.generateInto(publishOperation().info(), publishOperation().dependencies(),
- Path.of(workDirectory.getPath(), "pom.xml").toFile());
+ pomRoot();
}
}
diff --git a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java
index f090c8e..62b20f0 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java
@@ -1,7 +1,7 @@
/*
* Reasons.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@ package net.thauvin.erik.httpstatus;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -56,8 +57,8 @@ public final class Reasons {
// Initializes the reason phrases map.
static {
- final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_BASENAME);
- for (final String key : bundle.keySet()) {
+ var bundle = ResourceBundle.getBundle(BUNDLE_BASENAME);
+ for (var key : bundle.keySet()) {
REASON_PHRASES.put(key, bundle.getString(key));
}
}
@@ -75,7 +76,7 @@ public final class Reasons {
* @param statusCode The status code.
* @return The reason phrase, or null
.
*/
- public static String getReasonPhrase(final int statusCode) {
+ public static String getReasonPhrase(int statusCode) {
return getReasonPhrase(Integer.toString(statusCode));
}
@@ -85,7 +86,7 @@ public final class Reasons {
* @param statusCode The status code.
* @return The reason phrase, or null
.
*/
- public static String getReasonPhrase(final String statusCode) {
+ public static String getReasonPhrase(String statusCode) {
return REASON_PHRASES.get(statusCode);
}
@@ -95,29 +96,26 @@ public final class Reasons {
* @param args The status code(s) or response class(es), prints all if none.
*/
@SuppressWarnings("PMD.SystemPrintln")
- public static void main(final String... args) {
+ public static void main(String... args) {
+ var keys = new TreeSet<>(REASON_PHRASES.keySet());
if (args.length >= 1) {
- for (final String key : args) {
- if (key.endsWith("xx")) {
- var responseClass = key.charAt(0);
- REASON_PHRASES.forEach((k, v) -> {
+ for (var arg : args) {
+ if (arg.endsWith("xx")) { // e.g.: 2xx
+ var responseClass = arg.charAt(0);
+ keys.forEach(k -> {
if (k.charAt(0) == responseClass) {
- System.out.println(k + ": " + v);
+ System.out.println(k + ": " + REASON_PHRASES.get(k));
}
});
- } else {
- final String value = REASON_PHRASES.get(key);
+ } else { // e.g.: 404
+ var value = REASON_PHRASES.get(arg);
if (value != null) {
- System.out.println(key + ": " + value);
+ System.out.println(arg + ": " + value);
}
}
}
- } else {
- REASON_PHRASES.forEach((k, v) -> {
- if (v != null) {
- System.out.println(k + ": " + v);
- }
- });
+ } else { // Print all
+ keys.forEach(k -> System.out.println(k + ": " + REASON_PHRASES.get(k)));
System.out.println("Total: " + REASON_PHRASES.size());
}
}
diff --git a/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java b/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java
index 1982200..bbcb2ea 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/StatusCode.java
@@ -1,7 +1,7 @@
/*
* StatusCode.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@ public class StatusCode implements Serializable {
*
* @param code The status code.
*/
- public StatusCode(final int code) {
+ public StatusCode(int code) {
this.code = code;
}
@@ -139,7 +139,7 @@ public class StatusCode implements Serializable {
* @return true
if the status code is valid, false
otherwise.
*/
public boolean isValid() {
- return code >= 100 && code < 600;
+ return code == 783 || (code >= 100 && code < 600);
}
/**
@@ -147,7 +147,7 @@ public class StatusCode implements Serializable {
*
* @param code The HTTP status code.
*/
- public void setCode(final int code) {
+ public void setCode(int code) {
this.code = code;
}
}
diff --git a/src/main/java/net/thauvin/erik/httpstatus/Utils.java b/src/main/java/net/thauvin/erik/httpstatus/Utils.java
index 35422f3..5d42b22 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/Utils.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/Utils.java
@@ -1,7 +1,7 @@
/*
* Utils.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,11 +59,11 @@ public final class Utils {
* @param value The string value to convert.
* @return The converted string value.
*/
- public static String escapeXml(final String value) {
- final StringBuilder escaped = new StringBuilder();
+ public static String escapeXml(String value) {
+ var escaped = new StringBuilder();
- for (int i = 0; i < value.length(); i++) {
- final char c = value.charAt(i);
+ for (var i = 0; i < value.length(); i++) {
+ var c = value.charAt(i);
switch (c) {
case '<' -> escaped.append("<");
case '>' -> escaped.append(">");
@@ -86,7 +86,7 @@ public final class Utils {
* @param xml The {@link #escapeXml(String) xml} flag.
* @throws IOException If an I/O error occurs.
*/
- public static void outWrite(final Writer out, final String value, final String defaultValue, final boolean xml)
+ public static void outWrite(Writer out, String value, String defaultValue, boolean xml)
throws IOException {
if (value != null) {
out.write(xml ? escapeXml(value) : value);
diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java
index 6d54fe9..2bf4018 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java
@@ -1,7 +1,7 @@
/*
* CauseTag.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,7 @@ import net.thauvin.erik.httpstatus.Utils;
import java.io.IOException;
+
/**
* The <hs:cause>
tag returns the cause (if any) for the current HTTP Status Error Code.
*
@@ -47,14 +48,16 @@ import java.io.IOException;
*/
public class CauseTag extends XmlSupport {
/**
- * {@inheritDoc}
+ * Prints the cause (if any) for the current HTTP Status Error Code.
+ *
+ * @throws IOException If an error occurs while writing the output.
*/
@Override
public void doTag() throws IOException {
- final PageContext pageContext = (PageContext) getJspContext();
- final JspWriter out = pageContext.getOut();
+ PageContext pageContext = (PageContext) getJspContext();
+ JspWriter out = pageContext.getOut();
- final Throwable cause = pageContext.getErrorData().getThrowable().getCause();
+ Throwable cause = pageContext.getErrorData().getThrowable().getCause();
Utils.outWrite(out, getCause(cause), defaultValue, escapeXml);
}
@@ -72,4 +75,4 @@ public class CauseTag extends XmlSupport {
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java
index df9378a..f74b016 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java
@@ -1,7 +1,7 @@
/*
* CodeTag.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,12 +47,14 @@ import java.io.IOException;
*/
public class CodeTag extends SimpleTagSupport {
/**
- * {@inheritDoc}
+ * Writes the HTTP Status Error Code to the current JspWriter.
+ *
+ * @throws IOException If an I/O error occurs.
*/
@Override
public void doTag() throws IOException {
- final PageContext pageContext = (PageContext) getJspContext();
- final JspWriter out = pageContext.getOut();
+ PageContext pageContext = (PageContext) getJspContext();
+ JspWriter out = pageContext.getOut();
out.write(String.valueOf(pageContext.getErrorData().getStatusCode()));
}
diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/MessageTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/MessageTag.java
index f7d2ebc..7674774 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/MessageTag.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/MessageTag.java
@@ -1,7 +1,7 @@
/*
* MessageTag.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -47,14 +47,16 @@ import java.io.IOException;
*/
public class MessageTag extends XmlSupport {
/**
- * {@inheritDoc}
+ * Writes the error message associated with the current HTTP Status Error Code.
+ *
+ * @throws IOException If an I/O error occurs.
*/
@Override
public void doTag() throws IOException {
- final PageContext pageContext = (PageContext) getJspContext();
- final JspWriter out = pageContext.getOut();
+ PageContext pageContext = (PageContext) getJspContext();
+ JspWriter out = pageContext.getOut();
- final String message = (String) pageContext.getRequest().getAttribute(
+ String message = (String) pageContext.getRequest().getAttribute(
jakarta.servlet.RequestDispatcher.ERROR_MESSAGE);
Utils.outWrite(out, message, defaultValue, escapeXml);
diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java
index b80ddfa..16cd818 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java
@@ -1,7 +1,7 @@
/*
* ReasonTag.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -51,12 +51,12 @@ public class ReasonTag extends XmlSupport {
private int statusCode = -1;
/**
- * {@inheritDoc}
+ * Writes the Reason Phrase for the current (or specified) HTTP Status Error Code.
*/
@Override
public void doTag() {
- final PageContext pageContext = (PageContext) getJspContext();
- final JspWriter out = pageContext.getOut();
+ PageContext pageContext = (PageContext) getJspContext();
+ JspWriter out = pageContext.getOut();
try {
if (statusCode > -1) {
@@ -75,7 +75,7 @@ public class ReasonTag extends XmlSupport {
*
* @param statusCode The status code.
*/
- public void setCode(final int statusCode) {
+ public void setCode(int statusCode) {
this.statusCode = statusCode;
}
}
diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java
index 5fec8d7..5898da1 100644
--- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java
+++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java
@@ -1,7 +1,7 @@
/*
* XmlSupport.java
*
- * Copyright 2015-2023 Erik C. Thauvin (erik@thauvin.net)
+ * Copyright 2015-2025 Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@ public abstract class XmlSupport extends SimpleTagSupport {
* @param defaultValue The default value.
*/
@SuppressWarnings("unused")
- public void setDefault(final String defaultValue) {
+ public void setDefault(String defaultValue) {
this.defaultValue = defaultValue;
}
@@ -68,7 +68,7 @@ public abstract class XmlSupport extends SimpleTagSupport {
* @param escapeXml true
or false
*/
@SuppressWarnings("unused")
- public void setEscapeXml(final boolean escapeXml) {
+ public void setEscapeXml(boolean escapeXml) {
this.escapeXml = escapeXml;
}
}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/httpstatus.tld b/src/main/resources/META-INF/httpstatus.tld
index 0766792..eb1a1d5 100644
--- a/src/main/resources/META-INF/httpstatus.tld
+++ b/src/main/resources/META-INF/httpstatus.tld
@@ -2,7 +2,7 @@