About Question enthuware.ocpjp.v11.2.3638 :
Moderators: Site Manager, fjwalraven
-
- Posts: 1
- Joined: Wed Apr 07, 2021 3:18 am
- Contact:
About Question enthuware.ocpjp.v11.2.3638 :
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;
});
}
public void setApprovedUsers(final List<String> userids) {
return AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
this.userManager.setApprovedUsers(userids);
return null;
});
}
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
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
You may also check the example given here: https://docs.oracle.com/javase/8/docs/t ... leged.html
If you like our products and services, please help us by posting your review here.
-
- Posts: 18
- Joined: Fri Feb 05, 2021 3:37 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
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.
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.
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
You are right. It should use List.of instead of Collections.unmodifiableList. Fixed.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Tue Apr 13, 2021 4:22 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
Small typoWhile working on a code cleaup project fo
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
Fixed.
thank you for your feedback!
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 2
- Joined: Sun May 02, 2021 9:33 am
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
IMHO List.of(userids) is not correct, it creates a List of a List...
-
- Site Admin
- Posts: 10078
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v11.2.3638 :
You are right. It should be copyOf.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 11 guests