You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stefan Bodewig <bo...@apache.org> on 2018/04/11 07:57:49 UTC

Re: ant git commit: More isEmpty()

On 2018-04-06, <gi...@apache.org> wrote:

> http://git-wip-us.apache.org/repos/asf/ant/blob/c3b91f90/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
> ----------------------------------------------------------------------
> diff --git a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
> index e4b9d12..eea603d 100644
> --- a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
>>>> b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
> @@ -223,7 +223,7 @@ public abstract class ArchiveFileSet extends FileSet {
>       */
>      public void setPrefix(String prefix) {
>          checkArchiveAttributesAllowed();
> -        if (!"".equals(prefix) && !"".equals(fullpath)) {
> +        if (!prefix.isEmpty() && !fullpath.isEmpty()) {
>              throw new BuildException(ERROR_PATH_AND_PREFIX);
>          }
>          this.prefix = prefix;
> @@ -250,7 +250,7 @@ public abstract class ArchiveFileSet extends FileSet {
>       */
>      public void setFullpath(String fullpath) {
>          checkArchiveAttributesAllowed();
> -        if (!"".equals(prefix) && !"".equals(fullpath)) {
> +        if (!prefix.isEmpty() && !fullpath.isEmpty()) {
>              throw new BuildException(ERROR_PATH_AND_PREFIX);
>          }
>          this.fullpath = fullpath;

in both hunks prefix or fullpath could be null. Obviously the old code
doesn't handle this properly either. Do we want to keep assuming nobody
invokes either method with a null argument? I'm afraid we aren't really
consistent with the attribute setters dealing with null args.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: ant git commit: More isEmpty()

Posted by Stefan Bodewig <bo...@apache.org>.
On 2018-04-13, Jaikiran Pai wrote:

> I think we could probably document that passing null to such attribute
> setters will lead to NullPointerException, which most likely will be
> the case in a lot of places other than those that just set the
> incoming value to some member variable.

Agreed. In that case the change as such is fine.

Any idea where to put documentation like this?

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: ant git commit: More isEmpty()

Posted by Jaikiran Pai <ja...@gmail.com>.
On 11/04/18 1:27 PM, Stefan Bodewig wrote:
> On 2018-04-06, <gi...@apache.org> wrote:
>
>> http://git-wip-us.apache.org/repos/asf/ant/blob/c3b91f90/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
>> ----------------------------------------------------------------------
>> diff --git a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
>> index e4b9d12..eea603d 100644
>> --- a/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
>>>>> b/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
>> @@ -223,7 +223,7 @@ public abstract class ArchiveFileSet extends FileSet {
>>        */
>>       public void setPrefix(String prefix) {
>>           checkArchiveAttributesAllowed();
>> -        if (!"".equals(prefix) && !"".equals(fullpath)) {
>> +        if (!prefix.isEmpty() && !fullpath.isEmpty()) {
>>               throw new BuildException(ERROR_PATH_AND_PREFIX);
>>           }
>>           this.prefix = prefix;
>> @@ -250,7 +250,7 @@ public abstract class ArchiveFileSet extends FileSet {
>>        */
>>       public void setFullpath(String fullpath) {
>>           checkArchiveAttributesAllowed();
>> -        if (!"".equals(prefix) && !"".equals(fullpath)) {
>> +        if (!prefix.isEmpty() && !fullpath.isEmpty()) {
>>               throw new BuildException(ERROR_PATH_AND_PREFIX);
>>           }
>>           this.fullpath = fullpath;
> in both hunks prefix or fullpath could be null. Obviously the old code
> doesn't handle this properly either. Do we want to keep assuming nobody
> invokes either method with a null argument? I'm afraid we aren't really
> consistent with the attribute setters dealing with null args.
>
I think we could probably document that passing null to such attribute 
setters will lead to NullPointerException, which most likely will be the 
case in a lot of places other than those that just set the incoming 
value to some member variable.

-Jaikiran


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org