use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.
the class Http1to2Framing method channelRead.
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (!(msg instanceof Http2Frame))
throw new EUnexpected();
var frame = (Http2Frame) msg;
var httpObjs = translateResponseFrame(frame);
for (var httpObj : httpObjs) ctx.fireChannelRead(httpObj);
}
use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.
the class ConfigHelpers method copyConfigFromJar.
public static void copyConfigFromJar(String jarPath, String rootConfigPath, Path targetDir) throws IOException {
try (var jar = new JarFile(jarPath)) {
for (var entries = jar.entries(); entries.hasMoreElements(); ) {
var entry = entries.nextElement();
var name = entry.getName();
if (!name.startsWith(rootConfigPath))
continue;
if (entry.isDirectory())
Files.createDirectory(targetDir.resolve(name));
else {
try (var stream = jar.getInputStream(entry)) {
var size = entry.getSize();
var bytes = new byte[(int) size];
var sizeRead = stream.read(bytes);
if (sizeRead != size)
throw new EUnexpected();
Files.write(targetDir.resolve(name), bytes);
}
}
}
}
}
use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.
the class ValidationContext method pushList.
private ValidationContext pushList(Integer index) {
var parentLoc = location.peek();
if (!parentLoc.field().isRepeated() || parentLoc.field().isMapField())
throw new EUnexpected();
var list = (List<?>) parentLoc.target();
var priorList = (List<?>) parentLoc.prior();
var obj = list.get(index);
var priorObj = priorList != null ? priorList.get(index) : null;
var fieldName = String.format("[%d]", index);
var loc = new ValidationLocation(parentLoc, null, obj, priorObj, null, parentLoc.field(), fieldName);
if (parentLoc.skipped())
loc.skip();
location.push(loc);
return this;
}
use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.
the class ValidationContext method applyList.
public <TMsg extends Message> ValidationContext applyList(ValidationFunction.Typed<TMsg> validator, Class<TMsg> msgClass) {
if (done())
return this;
var loc = location.peek();
if (!loc.field().isRepeated() || loc.field().isMapField())
throw new EUnexpected();
var list = (List<?>) loc.target();
if (list == null)
throw new EUnexpected();
var resultCtx = this;
for (var i = 0; i < list.size(); i++) {
resultCtx = resultCtx.pushList(i).apply(validator, msgClass).pop();
}
return resultCtx;
}
use of com.accenture.trac.common.exception.EUnexpected in project tracdap by finos.
the class Http1Router method processRequestContent.
private void processRequestContent(ChannelHandlerContext ctx, HttpContent msg) {
try {
var request = requests.getOrDefault(currentInboundRequest, null);
if (request == null)
throw new EUnexpected();
if (REQUEST_STATUS_FINISHED.contains(request.status))
return;
if (!REQUEST_STATUS_CAN_RECEIVE.contains(request.status))
throw new EUnexpected();
var target = targets.getOrDefault(request.routeIndex, null);
if (target == null)
throw new EUnexpected();
msg.retain();
if (target.channel.isActive())
target.channel.write(msg);
else
target.outboundQueue.add(msg);
} finally {
ReferenceCountUtil.release(msg);
}
}
Aggregations