Page 1 of 1

About Question enthuware.ocpjp.v11.2.3638 :

Posted: Wed Apr 07, 2021 3:27 am
by darshanjoshi
As AccessController.doPrivileged method is not returning void, so below code will not compile.

public void setApprovedUsers(final List<String> userids) {
return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
this.userManager.setApprovedUsers(userids);
return null;
});
}

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Wed Apr 07, 2021 4:47 am
by admin
doPrivileged returns whatever PrivilegedAction's run method returns (given by the type of PrivilegedAction). Here, it returns Void because PrivilegedAction is typed to <Void>.
You may also check the example given here: https://docs.oracle.com/javase/8/docs/t ... leged.html

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Fri Apr 09, 2021 4:16 am
by minajev3
Sorry but I am pretty sure your guess is wrong
because if we just pass unmodifiableList - user(customer) will still have control over it using his original list
but the main rule is not trust to users and dont allow them more than necessary.

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Fri Apr 09, 2021 6:08 am
by admin
You are right. It should use List.of instead of Collections.unmodifiableList. Fixed.
thank you for your feedback!

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Sun Apr 18, 2021 12:34 pm
by palmada
While working on a code cleaup project fo
Small typo

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Mon Apr 19, 2021 7:13 am
by admin
Fixed.
thank you for your feedback!

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Sun May 16, 2021 11:10 am
by driesva
IMHO List.of(userids) is not correct, it creates a List of a List...

Re: About Question enthuware.ocpjp.v11.2.3638 :

Posted: Mon May 17, 2021 2:10 am
by admin
You are right. It should be copyOf.