Repository: wicket
Updated Branches:
  refs/heads/pr-86-media_tags 9d5daccdb -> 95e9eaa23


WICKET-5838 Last-modified header of external markup is ignored

Remove urlConnection#setDoInput(false) when checking for the last modification 
time of a URL.
The commit that introduced this change assumed that the URL is always pointing 
to a file in some .jar but this is not correct - the resource could be remote 
too.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/e93fdd5a
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/e93fdd5a
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/e93fdd5a

Branch: refs/heads/pr-86-media_tags
Commit: e93fdd5ab088d8638c5f1f58e2d337823cbcc020
Parents: 1861b9f
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Sat Feb 21 00:10:38 2015 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Sat Feb 21 00:10:38 2015 +0200

----------------------------------------------------------------------
 .../org/apache/wicket/util/io/Connections.java  |  1 -
 .../apache/wicket/util/io/ConnectionsTest.java  | 43 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/e93fdd5a/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
----------------------------------------------------------------------
diff --git 
a/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java 
b/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
index 5336af6..167cefd 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/io/Connections.java
@@ -57,7 +57,6 @@ public class Connections
 
                // otherwise open the url and proceed
                URLConnection connection = url.openConnection();
-               connection.setDoInput(false);
 
                final long milliseconds;
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/e93fdd5a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java 
b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java
new file mode 100644
index 0000000..cde53f6
--- /dev/null
+++ b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.io;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.notNullValue;
+
+import java.net.URL;
+
+import org.apache.wicket.util.time.Time;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ConnectionsTest extends Assert
+{
+       /**
+        * https://issues.apache.org/jira/browse/WICKET-5838
+        * @throws Exception
+        */
+       @Test
+       public void getLastModified() throws Exception
+       {
+               URL url = new 
URL("http://wicket.apache.org/learn/books/wia.png";);
+               Time lastModified = Connections.getLastModified(url);
+               assertThat(lastModified, is(notNullValue()));
+               assertThat(lastModified.getMilliseconds(), is(not(0L)));
+       }
+}

Reply via email to