在源码中无意看到了label的使用,注意label是一种用法而不是关键字。
在 package org.apache.catalina.core;
的final class StandardWrapperValve extends ValveBase {}
中看到这段代码。catalina
是Tomcat的核心组件,提供了Tomcat servlet规范的实际实现1
......
label1177: {
label1178: {
label1179: {
label1180: {
label1181: {
try {
label1122: {
try {
var47 = true;
if (servlet != null) {
if (filterChain != null) {
if (context.getSwallowOutput()) {
boolean var72 = false;
try {
var72 = true;
SystemLogHandler.startCapture();
if (request.isAsyncDispatching()) {
request.getAsyncContextInternal().doInternalDispatch();
var72 = false;
} else {
filterChain.doFilter(request.getRequest(), response.getResponse());
var72 = false;
}
} finally {
if (var72) {
String log = SystemLogHandler.stopCapture();
if (log != null && log.length() > 0) {
context.getLogger().info(log);
}
}
}
String log = SystemLogHandler.stopCapture();
if (log != null) {
if (log.length() > 0) {
context.getLogger().info(log);
var47 = false;
} else {
var47 = false;
}
} else {
var47 = false;
}
} else if (request.isAsyncDispatching()) {
request.getAsyncContextInternal().doInternalDispatch();
var47 = false;
} else {
filterChain.doFilter(request.getRequest(), response.getResponse());
var47 = false;
}
} else {
var47 = false;
}
} else {
var47 = false;
}
break label1177;
} catch (CloseNowException | ClientAbortException var88) {
if (container.getLogger().isDebugEnabled()) {
container.getLogger().debug(sm.getString("standardWrapper.serviceException", new Object[]{wrapper.getName(), context.getName()}), var88);
}
} catch (IOException var89) {
container.getLogger().error(sm.getString("standardWrapper.serviceException", new Object[]{wrapper.getName(), context.getName()}), var89);
throwable = var89;
this.exception(request, response, var89);
var47 = false;
break label1178;
} catch (UnavailableException var90) {
container.getLogger().error(sm.getString("standardWrapper.serviceException", new Object[]{wrapper.getName(), context.getName()}), var90);
wrapper.unavailable(var90);
long available = wrapper.getAvailable();
if (available > 0L && available < 9223372036854775807L) {
response.setDateHeader("Retry-After", available);
response.sendError(503, sm.getString("standardWrapper.isUnavailable", new Object[]{wrapper.getName()}));
var47 = false;
} else if (available == 9223372036854775807L) {
response.sendError(404, sm.getString("standardWrapper.notFound", new Object[]{wrapper.getName()}));
var47 = false;
} else {
var47 = false;
}
break label1181;
} catch (ServletException var91) {
Throwable rootCause = StandardWrapper.getRootCause(var91);
if (!(rootCause instanceof ClientAbortException)) {
container.getLogger().error(sm.getString("standardWrapper.serviceExceptionRoot", new Object[]{wrapper.getName(), context.getName(), var91.getMessage()}), rootCause);
}
throwable = var91;
this.exception(request, response, var91);
var47 = false;
break label1122;
} catch (Throwable var92) {
ExceptionUtils.handleThrowable(var92);
container.getLogger().error(sm.getString("standardWrapper.serviceException", new Object[]{wrapper.getName(), context.getName()}), var92);
throwable = var92;
this.exception(request, response, var92);
var47 = false;
break label1180;
}
throwable = var88;
this.exception(request, response, var88);
var47 = false;
break label1179;
}
} finally {
if (var47) {
if (filterChain != null) {
filterChain.release();
}
try {
if (servlet != null) {
wrapper.deallocate(servlet);
}
} catch (Throwable var74) {
ExceptionUtils.handleThrowable(var74);
container.getLogger().error(sm.getString("standardWrapper.deallocateException", new Object[]{wrapper.getName()}), var74);
if (throwable == null) {
throwable = var74;
this.exception(request, response, var74);
}
}
try {
if (servlet != null && wrapper.getAvailable() == 9223372036854775807L) {
wrapper.unload();
}
} catch (Throwable var73) {
ExceptionUtils.handleThrowable(var73);
container.getLogger().error(sm.getString("standardWrapper.unloadException", new Object[]{wrapper.getName()}), var73);
if (throwable == null) {
this.exception(request, response, var73);
}
}
long t2 = System.currentTimeMillis();
long time = t2 - t1;
this.processingTime += time;
if (time > this.maxTime) {
this.maxTime = time;
}
if (time < this.minTime) {
this.minTime = time;
}
}
}
if (filterChain != null) {
filterChain.release();
}
try {
if (servlet != null) {
wrapper.deallocate(servlet);
}
} catch (Throwable var84) {
ExceptionUtils.handleThrowable(var84);
container.getLogger().error(sm.getString("standardWrapper.deallocateException", new Object[]{wrapper.getName()}), var84);
if (throwable == null) {
throwable = var84;
this.exception(request, response, var84);
}
}
try {
if (servlet != null && wrapper.getAvailable() == 9223372036854775807L) {
wrapper.unload();
}
} catch (Throwable var83) {
ExceptionUtils.handleThrowable(var83);
container.getLogger().error(sm.getString("standardWrapper.unloadException", new Object[]{wrapper.getName()}), var83);
if (throwable == null) {
this.exception(request, response, var83);
}
}
t2 = System.currentTimeMillis();
time = t2 - t1;
this.processingTime += time;
if (time > this.maxTime) {
this.maxTime = time;
}
if (time < this.minTime) {
this.minTime = time;
}
return;
}
if (filterChain != null) {
filterChain.release();
}
try {
if (servlet != null) {
wrapper.deallocate(servlet);
}
} catch (Throwable var82) {
ExceptionUtils.handleThrowable(var82);
container.getLogger().error(sm.getString("standardWrapper.deallocateException", new Object[]{wrapper.getName()}), var82);
if (throwable == null) {
throwable = var82;
this.exception(request, response, var82);
}
}
try {
if (servlet != null && wrapper.getAvailable() == 9223372036854775807L) {
wrapper.unload();
}
} catch (Throwable var81) {
ExceptionUtils.handleThrowable(var81);
container.getLogger().error(sm.getString("standardWrapper.unloadException", new Object[]{wrapper.getName()}), var81);
if (throwable == null) {
this.exception(request, response, var81);
}
}
t2 = System.currentTimeMillis();
time = t2 - t1;
this.processingTime += time;
if (time > this.maxTime) {
this.maxTime = time;
}
if (time < this.minTime) {
this.minTime = time;
}
return;
}
if (filterChain != null) {
filterChain.release();
}
try {
if (servlet != null) {
wrapper.deallocate(servlet);
}
} catch (Throwable var86) {
ExceptionUtils.handleThrowable(var86);
container.getLogger().error(sm.getString("standardWrapper.deallocateException", new Object[]{wrapper.getName()}), var86);
if (throwable == null) {
throwable = var86;
this.exception(request, response, var86);
}
}
try {
if (servlet != null && wrapper.getAvailable() == 9223372036854775807L) {
wrapper.unload();
}
} catch (Throwable var85) {
ExceptionUtils.handleThrowable(var85);
container.getLogger().error(sm.getString("standardWrapper.unloadException", new Object[]{wrapper.getName()}), var85);
if (throwable == null) {
this.exception(request, response, var85);
}
}
t2 = System.currentTimeMillis();
time = t2 - t1;
this.processingTime += time;
if (time > this.maxTime) {
this.maxTime = time;
}
if (time < this.minTime) {
this.minTime = time;
}
return;
}
if (filterChain != null) {
filterChain.release();
}
try {
if (servlet != null) {
wrapper.deallocate(servlet);
}
} catch (Throwable var78) {
ExceptionUtils.handleThrowable(var78);
container.getLogger().error(sm.getString("standardWrapper.deallocateException", new Object[]{wrapper.getName()}), var78);
if (throwable == null) {
throwable = var78;
this.exception(request, response, var78);
}
}
try {
if (servlet != null && wrapper.getAvailable() == 9223372036854775807L) {
wrapper.unload();
}
} catch (Throwable var77) {
ExceptionUtils.handleThrowable(var77);
container.getLogger().error(sm.getString("standardWrapper.unloadException", new Object[]{wrapper.getName()}), var77);
if (throwable == null) {
this.exception(request, response, var77);
}
}
t2 = System.currentTimeMillis();
time = t2 - t1;
this.processingTime += time;
if (time > this.maxTime) {
this.maxTime = time;
}
if (time < this.minTime) {
this.minTime = time;
}
return;
}
if (filterChain != null) {
filterChain.release();
}
try {
if (servlet != null) {
wrapper.deallocate(servlet);
}
} catch (Throwable var80) {
ExceptionUtils.handleThrowable(var80);
container.getLogger().error(sm.getString("standardWrapper.deallocateException", new Object[]{wrapper.getName()}), var80);
if (throwable == null) {
throwable = var80;
this.exception(request, response, var80);
}
}
try {
if (servlet != null && wrapper.getAvailable() == 9223372036854775807L) {
wrapper.unload();
}
} catch (Throwable var79) {
ExceptionUtils.handleThrowable(var79);
container.getLogger().error(sm.getString("standardWrapper.unloadException", new Object[]{wrapper.getName()}), var79);
if (throwable == null) {
this.exception(request, response, var79);
}
}
t2 = System.currentTimeMillis();
time = t2 - t1;
this.processingTime += time;
if (time > this.maxTime) {
this.maxTime = time;
}
if (time < this.minTime) {
this.minTime = time;
}
return;
}
......
还有别的事情,先记着,有时间了再来看代码逻辑。