Skip to content

Commit

Permalink
Added null check to Accept header parsing, upped KEE version, added J…
Browse files Browse the repository at this point in the history
…ava 18 to CI
  • Loading branch information
urbim committed Dec 5, 2022
1 parent c310d95 commit fe0b32c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/kumuluzee-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
java-version: ['11', '17']
java-version: ['11', '17', '18']

steps:
- name: Checkout code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;

/**
* Utility class for media type (Accept header) parsing.
* Utility class for media type ('Accept' header) parsing.
*
* @author Urban Malc
* @since 2.0.0
Expand All @@ -48,10 +48,15 @@ public enum ReturnType {
UNKNOWN
}

public static ReturnType parseMediaType(String headers) {
public static ReturnType parseMediaType(String acceptHeader) {

if (acceptHeader == null) {
return ReturnType.PROMETHEUS;
}

List<MediaTypeTuple> parsedHeaders = new ArrayList<>();

for (String header : headers.split(",")) {
for (String header : acceptHeader.split(",")) {
String[] headerElements = header.split(";");

if (!KNOWN_HEADERS.contains(headerElements[0])) {
Expand All @@ -69,7 +74,7 @@ public static ReturnType parseMediaType(String headers) {
}

if (parsedHeaders.size() == 0) {
if (headers.length() > 0) {
if (acceptHeader.length() > 0) {
// no known headers
return ReturnType.UNKNOWN;
} else {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<jaxb-api.version>2.3.1</jaxb-api.version>

<kumuluzee.version>3.13.0-SNAPSHOT</kumuluzee.version>
<kumuluzee.version>4.1.0</kumuluzee.version>
<kumuluzee-config-mp.version>1.4.1</kumuluzee-config-mp.version>

<microprofile-metrics.version>3.0</microprofile-metrics.version>
Expand Down

0 comments on commit fe0b32c

Please sign in to comment.