[spring-extensions] branch maint-5 updated: Allow for negative durations.

Scott Cantor cantor.2 at osu.edu
Tue Mar 27 22:52:34 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch maint-5
in repository spring-extensions.

View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=2e957f0b5a1006c8175da44d62987c88042375ee

The following commit(s) were added to refs/heads/maint-5 by this push:
       new  2e957f0   Allow for negative durations.
2e957f0 is described below

commit 2e957f0b5a1006c8175da44d62987c88042375ee
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Mar 27 22:52:31 2018 -0400

    Allow for negative durations.
    
    Actual properties and arguments should impose constraint checks.
---
 .../shibboleth/ext/spring/config/DurationPropertyEditor.java   |  4 +---
 .../shibboleth/ext/spring/config/DurationToLongConverter.java  | 10 +++-------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java b/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java
index 9197e7f..8b7684c 100644
--- a/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java
+++ b/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java
@@ -30,10 +30,8 @@ public class DurationPropertyEditor extends PropertyEditorSupport {
     /** {@inheritDoc} */
     @Override public void setAsText(final String text) {
 
-        if (text.startsWith("P")) {
+        if (text.startsWith("P") || text.startsWith("-P")) {
             setValue(DOMTypeSupport.getDataTypeFactory().newDuration(text.trim()));
-        } else if (text.startsWith("-P")) {
-            throw new IllegalArgumentException("Negative durations are not supported");
         } else {
             setValue(DOMTypeSupport.getDataTypeFactory().newDuration(Long.valueOf(text)));
         }
diff --git a/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java b/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java
index 69e30c8..47c74ee 100644
--- a/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java
+++ b/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java
@@ -38,17 +38,13 @@ public class DurationToLongConverter implements Converter<String,Long>, Conditio
 
     /** {@inheritDoc} */
     @Override public Long convert(final String source) {
-        if (source.startsWith("P")) {
+        if (source.startsWith("P") || source.startsWith("-P")) {
             return DOMTypeSupport.durationToLong(source.trim());
-        } else if (source.startsWith("-P")) {
-            throw new IllegalArgumentException("Negative duration syntax is not supported");
         } else {
             // Treat as a milliseconds.  But note this
             final long duration = Long.valueOf(source);
-            if (duration > 0) {
-                log.info("Deprecated duration of {} was specified. Use XML duration of {}", source,
-                        DOMTypeSupport.longToDuration(duration));
-            }
+            log.info("Deprecated duration of {} was specified. Use XML duration of {}", source,
+                    DOMTypeSupport.longToDuration(duration));
             return duration;
         }
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list