Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last-Modified header is garbled when accessing wadl document on Japanese locale #5698

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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