[spring-extensions] 01/05: Allow for negative durations.
Ian Young
ian at iay.org.uk
Mon Jul 30 12:11:29 EDT 2018
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository spring-extensions.
View the commit online:
http://git.shibboleth.net/view/?p=spring-extensions.git;a=commit;h=8c5273d8c571e1f5c69d4c4a53f4e0f9be654ac3
commit 8c5273d8c571e1f5c69d4c4a53f4e0f9be654ac3
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