From 1dab0ca69239714516a971406fa6053d0db61137 Mon Sep 17 00:00:00 2001 From: nash Date: Tue, 26 Oct 2010 17:20:40 +0000 Subject: Merge r1025776 TUSCANY-3742: Fix time comparison for If-Modified-Since and If-Unmodified-Since; also merge r1025533 Fix typos git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027658 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/atom/provider/AtomBindingListenerServlet.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sca-java-1.x/trunk/modules/binding-atom-abdera/src/main/java/org') diff --git a/sca-java-1.x/trunk/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/sca-java-1.x/trunk/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java index 5ba07f5e22..3975fe1220 100644 --- a/sca-java-1.x/trunk/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java +++ b/sca-java-1.x/trunk/modules/binding-atom-abdera/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java @@ -278,7 +278,7 @@ class AtomBindingListenerServlet extends HttpServlet { if ( predicate != null ) { try { Date predicateDate = dateFormat.parse( predicate ); - if ( predicateDate.compareTo( feedUpdated ) < 0 ) { + if ( predicateDate.compareTo( exactSeconds(feedUpdated) ) < 0 ) { // Match, should short circuit response.sendError(HttpServletResponse.SC_NOT_MODIFIED); return; @@ -291,7 +291,7 @@ class AtomBindingListenerServlet extends HttpServlet { if ( predicate != null ) { try { Date predicateDate = dateFormat.parse( predicate ); - if ( predicateDate.compareTo( feedUpdated ) > 0 ) { + if ( predicateDate.compareTo( exactSeconds(feedUpdated) ) >= 0 ) { // Match, should short circuit response.sendError(HttpServletResponse.SC_NOT_MODIFIED); return; @@ -910,5 +910,13 @@ class AtomBindingListenerServlet extends HttpServlet { } } - + /** + * Round a date down to an exact number of seconds + * @param date with millisecond precision + * @return date rounded down to nearest second + */ + private Date exactSeconds(Date date) { + return new Date(date.getTime() / 1000 * 1000); + } + } -- cgit v1.2.3