You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Zepernick <Pa...@healthsmart.com> on 2018/08/21 16:32:00 UTC

Is HttpParameters Supposed to be Immutable

I was doing some work on a custom interceptor that was working with the HttpParameters class.  At first glance, it appears that it is supposed to be immutable based on some of the exceptions thrown for implementations of Map methods, for example:

   @Override
    public Parameter put(String key, Parameter value) {
        throw new IllegalAccessError("HttpParameters are immutable, you cannot put value directly!");
    }

    @Override
    public Parameter remove(Object key) {
        throw new IllegalAccessError("HttpParameters are immutable, you cannot remove object directly!");
    }


But then this method is there:

    public HttpParameters remove(Set<String> paramsToRemove) {
       for (String paramName : paramsToRemove) {
            parameters.remove(paramName);
        }
        return this;
    }

Which is removing the parameter from the object, I would have expected that this return a modified copy?

Just wondering the intentions of the class, and if this should be logged as a bug?

Paul



Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

RE: Is HttpParameters Supposed to be Immutable

Posted by Paul Zepernick <Pa...@healthsmart.com>.
Thanks for the feedback.  I will open up a bug and submit a PR 😊

Paul

-----Original Message-----
From: Lukasz Lenart <lu...@apache.org>
Sent: Wednesday, August 22, 2018 12:54 AM
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: Is HttpParameters Supposed to be Immutable

wt., 21 sie 2018 o 18:32 Paul Zepernick
<Pa...@healthsmart.com> napisał(a):
> Which is removing the parameter from the object, I would have expected that this return a modified copy?

Yes, you are right.

> Just wondering the intentions of the class, and if this should be logged as a bug?

I would say it's a bug. Raw http parameters are immutable by definition so this class should reflect the same behaviour, that was my intention. Feel free to register an issue and open a PR :)


Regards
--
Łukasz
+ 48 606 323 122
+ https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.le
+ nart.org.pl%2F&amp;data=02%7C01%7CPaul.Zepernick%40healthsmart.com%7Cd
+ 98c321b7e234f5771df08d607eb41ae%7C2ce547c5e80a40628a56f25adceefb52%7C0
+ %7C0%7C636705104334716954&amp;sdata=l1i2g3uBxTjEP68wCkgokRAJYi%2BUOnhH
+ 9Lo3R009bQY%3D&amp;reserved=0

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

Re: Is HttpParameters Supposed to be Immutable

Posted by Lukasz Lenart <lu...@apache.org>.
wt., 21 sie 2018 o 18:32 Paul Zepernick
<Pa...@healthsmart.com> napisał(a):
> Which is removing the parameter from the object, I would have expected that this return a modified copy?

Yes, you are right.

> Just wondering the intentions of the class, and if this should be logged as a bug?

I would say it's a bug. Raw http parameters are immutable by
definition so this class should reflect the same behaviour, that was
my intention. Feel free to register an issue and open a PR :)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org