Skip to content

Commit

Permalink
Last-Modified header is garbled when accessing wadl document on Japan…
Browse files Browse the repository at this point in the history
…ese locale (eclipse-ee4j#5698)

* Last-Modified header is garbled when accessing wadl document on Japanese locale
Signed-off-by: Vaibhav Vishal <[email protected]>
  • Loading branch information
vavishal authored and senivam committed Jul 25, 2024
1 parent c9924cf commit 8037b47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -21,6 +21,7 @@
import java.net.URI;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -62,7 +63,7 @@ public final class WadlResource {


public WadlResource() {
this.lastModified = new SimpleDateFormat(HTTPDATEFORMAT).format(new Date());
this.lastModified = new SimpleDateFormat(HTTPDATEFORMAT, Locale.US).format(new Date());
}

private boolean isCached(UriInfo uriInfo, boolean detailedWadl) {
Expand All @@ -81,7 +82,7 @@ public synchronized Response getWadl(@Context UriInfo uriInfo) {
if ((wadlXmlRepresentation == null) || (!isCached(uriInfo, detailedWadl))) {
this.lastBaseUri = uriInfo.getBaseUri();
lastDetailedWadl = detailedWadl;
this.lastModified = new SimpleDateFormat(HTTPDATEFORMAT).format(new Date());
this.lastModified = new SimpleDateFormat(HTTPDATEFORMAT, Locale.US).format(new Date());

ApplicationDescription applicationDescription = wadlContext.getApplication(uriInfo,
detailedWadl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -30,6 +30,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -108,6 +109,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -399,6 +401,20 @@ public void testLastModifiedGET() {
assertTrue(r.getHeaders().containsKey("Last-modified"));
}

@Test
public void testLastModifiedGETOnJPLocale() {
Locale defaultLocale = Locale.getDefault();
try {
Locale.setDefault(new Locale("ja", "JP"));
final WebTarget target = target("/application.wadl");

final Response r = target.queryParam(WadlUtils.DETAILED_WADL_QUERY_PARAM, "true").request().get(Response.class);
assertDoesNotThrow(() -> r.getLastModified());
} finally {
Locale.setDefault(defaultLocale);
}
}

@Test
public void testLastModifiedOPTIONS() {
final WebTarget target = target("/widgets/3/verbose");
Expand Down

0 comments on commit 8037b47

Please sign in to comment.