You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/10/15 18:13:44 UTC

[commons-beanutils] branch master updated (e6f7a533 -> 4ff0ed0c)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git


    from e6f7a533 Provide error index in ConversionException message in DateTimeConverter.parse(Class, Class, String, DateFormat)
     new 8f98c88d Inline single-use variable
     new b47cb0c9 Avoid possible NPE in DateTimeConverter.parse(Class, Class, String)
     new 4ff0ed0c Inline single-use variable

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                                       |  3 +++
 .../commons/beanutils2/converters/DateTimeConverter.java      | 11 ++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)


[commons-beanutils] 03/03: Inline single-use variable

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git

commit 4ff0ed0c3f9dcc81b3862d9489d67fd0553e6c38
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 15 14:11:40 2023 -0400

    Inline single-use variable
---
 .../org/apache/commons/beanutils2/converters/DateTimeConverter.java    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java b/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
index 5820469a..ac259ee4 100644
--- a/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
+++ b/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
@@ -462,8 +462,7 @@ public abstract class DateTimeConverter<D> extends AbstractConverter<D> {
             }
             throw new ConversionException(msg);
         }
-        final Calendar calendar = format.getCalendar();
-        return calendar;
+        return format.getCalendar();
     }
 
     /**


[commons-beanutils] 01/03: Inline single-use variable

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git

commit 8f98c88dca28d4747443246c4406300264ac269a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 15 14:07:40 2023 -0400

    Inline single-use variable
---
 .../org/apache/commons/beanutils2/converters/DateTimeConverter.java    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java b/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
index 71e43cba..ffc53152 100644
--- a/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
+++ b/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
@@ -417,8 +417,7 @@ public abstract class DateTimeConverter<D> extends AbstractConverter<D> {
         Exception firstEx = null;
         for (final String pattern : patterns) {
             try {
-                final DateFormat format = getFormat(pattern);
-                return parse(sourceType, targetType, value, format);
+                return parse(sourceType, targetType, value, getFormat(pattern));
             } catch (final Exception ex) {
                 if (firstEx == null) {
                     firstEx = ex;


[commons-beanutils] 02/03: Avoid possible NPE in DateTimeConverter.parse(Class, Class, String)

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git

commit b47cb0c963a0754d65f7b227f0798eb3334ae375
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 15 14:11:28 2023 -0400

    Avoid possible NPE in DateTimeConverter.parse(Class, Class, String)
---
 src/changes/changes.xml                                              | 3 +++
 .../org/apache/commons/beanutils2/converters/DateTimeConverter.java  | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 24308a63..c976656d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -113,6 +113,9 @@
       <action dev="ggregory" type="fix" due-to="Gary Gregory">
         Provide error index in ConversionException message in DateTimeConverter.parse(Class, Class, String, DateFormat).
       </action>
+      <action dev="ggregory" type="fix" due-to="Gary Gregory">
+        Avoid possible NPE in DateTimeConverter.parse(Class, Class, String).
+      </action>
       <!-- ADD -->
       <action dev="ggregory" type="add" due-to="Dependabot, Gary Gregory">
         Add github/codeql-action #118.
diff --git a/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java b/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
index ffc53152..5820469a 100644
--- a/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
+++ b/src/main/java/org/apache/commons/beanutils2/converters/DateTimeConverter.java
@@ -427,7 +427,10 @@ public abstract class DateTimeConverter<D> extends AbstractConverter<D> {
         if (patterns.length > 1) {
             throw ConversionException.format("Error converting '%s' to '%s' using  patterns '%s'", toString(sourceType), toString(targetType), displayPatterns);
         }
-        throw firstEx;
+        if (firstEx != null) {
+            throw firstEx;
+        }
+        return null;
     }
 
     /**