本文整理了Java中org.wildfly.common.Assert.unreachableCode()
方法的一些代码示例,展示了Assert.unreachableCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.unreachableCode()
方法的具体详情如下:
包路径:org.wildfly.common.Assert
类名称:Assert
方法名:unreachableCode
[英]Return an exception indicating that the current code was intended to be unreachable.
[中]返回一个异常,指示当前代码不可访问。
代码示例来源:origin: wildfly/wildfly
/**
* Attempt to determine whether the invocation should proceed or whether it should be cancelled. This method should only
* be called once per flag instance.
*
* @return {@code true} if the invocation should proceed, or {@code false} if it was cancelled
*/
public boolean runIfNotCancelled() {
final AtomicInteger stateRef = this.stateRef;
int oldVal;
do {
oldVal = stateRef.get();
if (oldVal == ST_CANCELLED || oldVal == ST_CANCELLED_FLAG_SET) {
return false;
} else if (oldVal != ST_WAITING) {
throw Assert.unreachableCode();
}
} while (! stateRef.compareAndSet(oldVal, ST_STARTED));
return true;
}
代码示例来源:origin: wildfly/wildfly
public void start(final Xid xid, final int flags) throws XAException {
if (flags == TMJOIN) {
// should be impossible
throw Assert.unreachableCode();
}
// ensure that the timeout is registered
startTime = System.nanoTime();
capturedTimeout = timeout;
lookup(xid);
this.xid = xid;
}
代码示例来源:origin: wildfly/wildfly
private static boolean unregisterDeferral(final JBossThread thread) {
if (thread == null) {
return false;
}
int oldVal, newVal;
final AtomicInteger stateRef = thread.stateRef;
do {
oldVal = stateRef.get();
if (oldVal == STATE_MAYBE_INTERRUPTED || oldVal == STATE_INTERRUPT_IN_PROGRESS) {
// already not deferred
return false;
} else if (oldVal == STATE_INTERRUPT_DEFERRED) {
newVal = STATE_MAYBE_INTERRUPTED;
} else if (oldVal == STATE_INTERRUPT_PENDING) {
newVal = STATE_INTERRUPT_IN_PROGRESS;
} else {
throw Assert.unreachableCode();
}
} while (! stateRef.compareAndSet(oldVal, newVal));
if (newVal == STATE_INTERRUPT_IN_PROGRESS) try {
thread.doInterrupt();
} finally {
stateRef.set(STATE_MAYBE_INTERRUPTED);
}
return true;
}
代码示例来源:origin: wildfly/wildfly
private static boolean registerDeferral(final JBossThread thread) {
if (thread == null) {
return false;
}
final AtomicInteger stateRef = thread.stateRef;
int oldVal, newVal;
do {
oldVal = stateRef.get();
while (oldVal == STATE_INTERRUPT_IN_PROGRESS) {
LockSupport.park();
oldVal = stateRef.get();
}
if (oldVal == STATE_MAYBE_INTERRUPTED) {
newVal = Thread.interrupted() ? STATE_INTERRUPT_DEFERRED : STATE_INTERRUPT_PENDING;
} else if (oldVal == STATE_INTERRUPT_DEFERRED || oldVal == STATE_INTERRUPT_PENDING) {
// already deferred
return false;
} else {
throw Assert.unreachableCode();
}
} while (! stateRef.compareAndSet(oldVal, newVal));
if (newVal == STATE_INTERRUPT_DEFERRED && Thread.interrupted()) {
// in case we got interrupted right after we checked interrupt state but before we CAS'd the value.
stateRef.set(STATE_INTERRUPT_PENDING);
}
return true;
}
代码示例来源:origin: wildfly/wildfly
nameBytes = nodeName.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
throw Assert.unreachableCode();
throw Assert.unreachableCode();
代码示例来源:origin: wildfly/wildfly
/**
* Determine if this CIDR address matches the given address.
*
* @param address the address to test
* @return {@code true} if the address matches, {@code false} otherwise
*/
public boolean matches(InetAddress address) {
Assert.checkNotNullParam("address", address);
if (address instanceof Inet4Address) {
return matches((Inet4Address) address);
} else if (address instanceof Inet6Address) {
return matches((Inet6Address) address);
} else {
throw Assert.unreachableCode();
}
}
代码示例来源:origin: wildfly/wildfly
return this.broadcast = (Inet4Address) InetAddress.getByAddress(Inet.toOptimalString(bytes), bytes);
} catch (UnknownHostException e) {
throw Assert.unreachableCode();
代码示例来源:origin: wildfly/wildfly
private static void parseInterceptorsType(final ConfigurationXMLStreamReader streamReader, final EJBClientContext.Builder builder) throws ConfigXMLParseException {
if (streamReader.getAttributeCount() > 0) {
throw streamReader.unexpectedAttribute(0);
}
for (;;) {
final int next = streamReader.nextTag();
if (next == START_ELEMENT) {
if (! streamReader.getNamespaceURI().equals(NS_EJB_CLIENT_3_0) || ! streamReader.getLocalName().equals("interceptor")) {
throw streamReader.unexpectedElement();
}
parseInterceptorType(streamReader, builder);
} else if (next == END_ELEMENT) {
return;
} else {
throw Assert.unreachableCode();
}
}
}
代码示例来源:origin: wildfly/wildfly
throw Assert.unreachableCode();
throw Assert.unreachableCode();
代码示例来源:origin: wildfly/wildfly
private static void parseConnectionsType(final ConfigurationXMLStreamReader streamReader, final EJBClientContext.Builder builder) throws ConfigXMLParseException {
if (streamReader.getAttributeCount() > 0) {
throw streamReader.unexpectedAttribute(0);
}
for (;;) {
final int next = streamReader.nextTag();
if (next == START_ELEMENT) {
if (! streamReader.getNamespaceURI().equals(NS_EJB_CLIENT_3_0)) {
throw streamReader.unexpectedElement();
}
final String localName = streamReader.getLocalName();
if (localName.equals("connection")) {
parseConnectionType(streamReader, builder);
} else {
throw streamReader.unexpectedElement();
}
} else if (next == END_ELEMENT) {
return;
} else {
throw Assert.unreachableCode();
}
}
}
代码示例来源:origin: wildfly/wildfly
return;
} else {
throw Assert.unreachableCode();
代码示例来源:origin: wildfly/wildfly
protected boolean isConnected(final URI uri) {
final IoFuture<ConnectionPeerIdentity> future = Endpoint.getCurrent().getConnectedIdentityIfExists(uri, "ejb", "jboss", AuthenticationContext.captureCurrent());
try {
return future != null && future.getStatus() == IoFuture.Status.DONE && future.get().getConnection().isOpen();
} catch (IOException e) {
// impossible
throw Assert.unreachableCode();
}
}
代码示例来源:origin: wildfly/wildfly
static CidrAddress create(byte[] addressBytes, int netmaskBits, boolean clone) {
Assert.checkNotNullParam("networkAddress", addressBytes);
Assert.checkMinimumParameter("netmaskBits", 0, netmaskBits);
final int length = addressBytes.length;
if (length == 4) {
Assert.checkMaximumParameter("netmaskBits", 32, netmaskBits);
if (netmaskBits == 0) {
return INET4_ANY_CIDR;
}
} else if (length == 16) {
Assert.checkMaximumParameter("netmaskBits", 128, netmaskBits);
if (netmaskBits == 0) {
return INET6_ANY_CIDR;
}
} else {
throw CommonMessages.msg.invalidAddressBytes(length);
}
final byte[] bytes = clone ? addressBytes.clone() : addressBytes;
maskBits0(bytes, netmaskBits);
String name = Inet.toOptimalString(bytes);
try {
return new CidrAddress(InetAddress.getByAddress(name, bytes), netmaskBits);
} catch (UnknownHostException e) {
throw Assert.unreachableCode();
}
}
代码示例来源:origin: wildfly/wildfly
return;
} else {
throw Assert.unreachableCode();
代码示例来源:origin: wildfly/wildfly
public IdentityCredentials with(final IdentityCredentials other) {
Assert.checkNotNullParam("other", other);
if (other == NONE) {
return this;
} else if (other instanceof One) {
return withCredential(((One) other).credential);
} else if (other instanceof Two) {
final Two otherTwo = (Two) other;
return withCredential(otherTwo.credential1).withCredential(otherTwo.credential2);
} else if (other instanceof Many) {
Many otherMany = (Many) other;
if (otherMany.containsMatching(credential1)) {
if (otherMany.containsMatching(credential2)) {
return otherMany;
} else {
return new Many(credential2, otherMany);
}
} else if (otherMany.containsMatching(credential2)) {
return new Many(credential1, otherMany);
} else {
return new Many(credential1, credential2, otherMany);
}
} else {
throw Assert.unreachableCode();
}
}
代码示例来源:origin: wildfly/wildfly
return;
} else {
throw Assert.unreachableCode();
代码示例来源:origin: wildfly/wildfly
/**
* Proceed with the next interceptor in the chain, calling the resolved receiver in the end.
*
* @return the session ID (not {@code null})
* @throws Exception if the EJB session creation failed for some reason
*/
public SessionID proceed() throws Exception {
final int idx = interceptorChainIndex++;
try {
final EJBClientInterceptorInformation[] chain = interceptorList.getInformation();
if (idx > chain.length) {
throw Assert.unreachableCode();
}
if (chain.length == idx) {
final URI destination = getDestination();
final EJBReceiver receiver = getClientContext().resolveReceiver(destination, getLocator());
setReceiver(receiver);
final SessionID sessionID = receiver.createSession(new EJBReceiverSessionCreationContext(this, authenticationContext));
if (sessionID == null) {
throw Logs.INVOCATION.nullSessionID(receiver, getLocator().asStateless());
}
retry = false;
return sessionID;
} else {
return chain[idx].getInterceptorInstance().handleSessionCreation(this);
}
} finally {
interceptorChainIndex --;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* The builder class for an {@code EnhancedQueueExecutor}. All the fields are initialized to sensible defaults for
* a small thread pool.
*/
public static final class Builder {
private ThreadFactory threadFactory = Executors.defaultThreadFactory();
private Runnable terminationTask = NullRunnable.getInstance();
private Executor handoffExecutor = DEFAULT_HANDLER;
private Thread.UncaughtExceptionHandler exceptionHandler = JBossExecutors.loggingExceptionHandler();
private int coreSize = 16;
private int maxSize = 64;
private long keepAliveTime = 30;
private TimeUnit keepAliveUnits = TimeUnit.SECONDS;
private float growthResistance;
private boolean allowCoreTimeOut;
private int maxQueueSize = Integer.MAX_VALUE;
private boolean registerMBean = REGISTER_MBEAN;
private String mBeanName;
/**
* Construct a new instance.
*/
public Builder() {}
/**
* Get the configured thread factory.
*
* @return the configured thread factory (not {@code null})
*/
public ThreadFactory getThreadFactory() {
代码示例来源:origin: wildfly/wildfly
throw Assert.unreachableCode();
代码示例来源:origin: org.wildfly.transaction/wildfly-transaction-client
public void start(final Xid xid, final int flags) throws XAException {
if (flags == TMJOIN) {
// should be impossible
throw Assert.unreachableCode();
}
// ensure that the timeout is registered
startTime = System.nanoTime();
capturedTimeout = timeout;
lookup(xid);
this.xid = xid;
}
内容来源于网络,如有侵权,请联系作者删除!