下面列出了java.security.AccessController#doPrivilegedWithCombiner ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void plainConnect() throws IOException {
synchronized (this) {
if (connected) {
return;
}
}
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<Void>() {
public Void run() throws IOException {
plainConnect0();
return null;
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
// run without additional permission
plainConnect0();
}
}
@Override
public synchronized OutputStream getOutputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<OutputStream>() {
public OutputStream run() throws IOException {
return getOutputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getOutputStream0();
}
}
@Override
public synchronized InputStream getInputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<InputStream>() {
public InputStream run() throws IOException {
return getInputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getInputStream0();
}
}
@Override
public synchronized OutputStream getOutputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<OutputStream>() {
public OutputStream run() throws IOException {
return getOutputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getOutputStream0();
}
}
@Override
public synchronized InputStream getInputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<InputStream>() {
public InputStream run() throws IOException {
return getInputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getInputStream0();
}
}
@Override
public synchronized OutputStream getOutputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<OutputStream>() {
public OutputStream run() throws IOException {
return getOutputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getOutputStream0();
}
}
@Override
public synchronized InputStream getInputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<InputStream>() {
public InputStream run() throws IOException {
return getInputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getInputStream0();
}
}
protected void plainConnect() throws IOException {
synchronized (this) {
if (connected) {
return;
}
}
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<Void>() {
public Void run() throws IOException {
plainConnect0();
return null;
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
// run without additional permission
plainConnect0();
}
}
@Override
public synchronized InputStream getInputStream() throws IOException {
connecting = true;
SocketPermission p = URLtoSocketPermission(this.url);
if (p != null) {
try {
return AccessController.doPrivilegedWithCombiner(
new PrivilegedExceptionAction<InputStream>() {
public InputStream run() throws IOException {
return getInputStream0();
}
}, null, p
);
} catch (PrivilegedActionException e) {
throw (IOException) e.getException();
}
} else {
return getInputStream0();
}
}
@Test(expectedExceptions = NullPointerException.class)
public void test3() {
AccessController.doPrivilegedWithCombiner(
(PrivilegedAction<Void>) () -> null, acc, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test4() {
AccessController.doPrivilegedWithCombiner(
(PrivilegedAction<Void>) () -> null, acc, p1, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test7() throws PrivilegedActionException {
AccessController.doPrivilegedWithCombiner(
(PrivilegedExceptionAction<Void>) () -> null,
acc, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test8() throws PrivilegedActionException {
AccessController.doPrivilegedWithCombiner(
(PrivilegedExceptionAction<Void>) () -> null,
acc, p1, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test7() throws PrivilegedActionException {
AccessController.doPrivilegedWithCombiner(
(PrivilegedExceptionAction<Void>) () -> null,
acc, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test3() {
AccessController.doPrivilegedWithCombiner(
(PrivilegedAction<Void>) () -> null, acc, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test3() {
AccessController.doPrivilegedWithCombiner(
(PrivilegedAction<Void>) () -> null, acc, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test7() throws PrivilegedActionException {
AccessController.doPrivilegedWithCombiner(
(PrivilegedExceptionAction<Void>) () -> null,
acc, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test8() throws PrivilegedActionException {
AccessController.doPrivilegedWithCombiner(
(PrivilegedExceptionAction<Void>) () -> null,
acc, p1, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test8() throws PrivilegedActionException {
AccessController.doPrivilegedWithCombiner(
(PrivilegedExceptionAction<Void>) () -> null,
acc, p1, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void test4() {
AccessController.doPrivilegedWithCombiner(
(PrivilegedAction<Void>) () -> null, acc, p1, null);
}