use of java.util.logging.Logger in project jersey by jersey.
the class HttpUrlConnector method _apply.
private ClientResponse _apply(final ClientRequest request) throws IOException {
final HttpURLConnection uc;
uc = this.connectionFactory.getConnection(request.getUri().toURL());
uc.setDoInput(true);
final String httpMethod = request.getMethod();
if (request.resolveProperty(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, setMethodWorkaround)) {
setRequestMethodViaJreBugWorkaround(uc, httpMethod);
} else {
uc.setRequestMethod(httpMethod);
}
uc.setInstanceFollowRedirects(request.resolveProperty(ClientProperties.FOLLOW_REDIRECTS, true));
uc.setConnectTimeout(request.resolveProperty(ClientProperties.CONNECT_TIMEOUT, uc.getConnectTimeout()));
uc.setReadTimeout(request.resolveProperty(ClientProperties.READ_TIMEOUT, uc.getReadTimeout()));
secureConnection(request.getClient(), uc);
final Object entity = request.getEntity();
if (entity != null) {
RequestEntityProcessing entityProcessing = request.resolveProperty(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.class);
if (entityProcessing == null || entityProcessing != RequestEntityProcessing.BUFFERED) {
final long length = request.getLengthLong();
if (fixLengthStreaming && length > 0) {
// uc.setFixedLengthStreamingMode(long) was introduced in JDK 1.7 and Jersey client supports 1.6+
if ("1.6".equals(Runtime.class.getPackage().getSpecificationVersion())) {
uc.setFixedLengthStreamingMode(request.getLength());
} else {
uc.setFixedLengthStreamingMode(length);
}
} else if (entityProcessing == RequestEntityProcessing.CHUNKED) {
uc.setChunkedStreamingMode(chunkSize);
}
}
uc.setDoOutput(true);
if ("GET".equalsIgnoreCase(httpMethod)) {
final Logger logger = Logger.getLogger(HttpUrlConnector.class.getName());
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, LocalizationMessages.HTTPURLCONNECTION_REPLACES_GET_WITH_ENTITY());
}
}
request.setStreamProvider(contentLength -> {
setOutboundHeaders(request.getStringHeaders(), uc);
return uc.getOutputStream();
});
request.writeEntity();
} else {
setOutboundHeaders(request.getStringHeaders(), uc);
}
final int code = uc.getResponseCode();
final String reasonPhrase = uc.getResponseMessage();
final Response.StatusType status = reasonPhrase == null ? Statuses.from(code) : Statuses.from(code, reasonPhrase);
final URI resolvedRequestUri;
try {
resolvedRequestUri = uc.getURL().toURI();
} catch (URISyntaxException e) {
throw new ProcessingException(e);
}
ClientResponse responseContext = new ClientResponse(status, request, resolvedRequestUri);
responseContext.headers(uc.getHeaderFields().entrySet().stream().filter(stringListEntry -> stringListEntry.getKey() != null).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
responseContext.setEntityStream(getInputStream(uc));
return responseContext;
}
use of java.util.logging.Logger in project jersey by jersey.
the class JerseyTest method unregisterLogHandler.
/**
* Un-register {@link Handler log handler} from the list of root loggers.
*/
private void unregisterLogHandler() {
for (final Logger root : getRootLoggers()) {
root.setLevel(logLevelMap.get(root));
root.removeHandler(getLogHandler());
}
logHandler = null;
}
use of java.util.logging.Logger in project jersey by jersey.
the class JerseyTest method registerLogHandler.
/**
* Register {@link Handler log handler} to the list of root loggers.
*/
private void registerLogHandler() {
final String recordLogLevel = getProperty(TestProperties.RECORD_LOG_LEVEL);
final int recordLogLevelInt = Integer.valueOf(recordLogLevel);
final Level level = Level.parse(recordLogLevel);
logLevelMap.clear();
for (final Logger root : getRootLoggers()) {
logLevelMap.put(root, root.getLevel());
if (root.getLevel().intValue() > recordLogLevelInt) {
root.setLevel(level);
}
root.addHandler(getLogHandler());
}
}
use of java.util.logging.Logger in project graphdb by neo4j-attic.
the class XaResourceManager method checkXids.
synchronized void checkXids() throws IOException {
msgLog.logMessage("XaResourceManager[" + name + "] sorting " + xidMap.size() + " xids");
Iterator<Xid> keyIterator = xidMap.keySet().iterator();
LinkedList<Xid> xids = new LinkedList<Xid>();
while (keyIterator.hasNext()) {
xids.add(keyIterator.next());
}
// comparator only used here
Collections.sort(xids, new Comparator<Xid>() {
public int compare(Xid o1, Xid o2) {
Integer id1 = txOrderMap.get(o1);
Integer id2 = txOrderMap.get(o2);
if (id1 == null && id2 == null) {
return 0;
}
if (id1 == null) {
return Integer.MAX_VALUE;
}
if (id2 == null) {
return Integer.MIN_VALUE;
}
return id1 - id2;
}
});
// = null;
txOrderMap.clear();
Logger logger = Logger.getLogger(tf.getClass().getName());
while (!xids.isEmpty()) {
Xid xid = xids.removeFirst();
XidStatus status = xidMap.get(xid);
TransactionStatus txStatus = status.getTransactionStatus();
XaTransaction xaTransaction = txStatus.getTransaction();
int identifier = xaTransaction.getIdentifier();
if (xaTransaction.isRecovered()) {
if (txStatus.commitStarted()) {
logger.fine("Marking 1PC [" + name + "] tx " + identifier + " as done");
log.doneInternal(identifier);
xidMap.remove(xid);
recoveredTxCount--;
} else if (!txStatus.prepared()) {
logger.fine("Rolling back non prepared tx [" + name + "]" + "txIdent[" + identifier + "]");
log.doneInternal(xaTransaction.getIdentifier());
xidMap.remove(xid);
recoveredTxCount--;
} else {
logger.fine("2PC tx [" + name + "] " + txStatus + " txIdent[" + identifier + "]");
}
}
}
checkIfRecoveryComplete();
}
use of java.util.logging.Logger in project graphdb by neo4j-attic.
the class TestNeo4jConstrains method testIllegalPropertyType.
@Test
public void testIllegalPropertyType() {
Logger log = Logger.getLogger(NodeManager.class.getName());
Level level = log.getLevel();
log.setLevel(Level.OFF);
try {
Node node1 = getGraphDb().createNode();
try {
node1.setProperty(key, new Object());
fail("Shouldn't validate");
} catch (Exception e) {
// good
}
try {
Transaction tx = getTransaction();
tx.success();
tx.finish();
fail("Shouldn't validate");
} catch (Exception e) {
}
// good
setTransaction(getGraphDb().beginTx());
try {
getGraphDb().getNodeById(node1.getId());
fail("Node should not exist, previous tx didn't rollback");
} catch (NotFoundException e) {
// good
}
node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel = node1.createRelationshipTo(node2, MyRelTypes.TEST);
try {
rel.setProperty(key, new Object());
fail("Shouldn't validate");
} catch (Exception e) {
// good
}
try {
Transaction tx = getTransaction();
tx.success();
tx.finish();
fail("Shouldn't validate");
} catch (Exception e) {
}
// good
setTransaction(getGraphDb().beginTx());
try {
getGraphDb().getNodeById(node1.getId());
fail("Node should not exist, previous tx didn't rollback");
} catch (NotFoundException e) {
// good
}
try {
getGraphDb().getNodeById(node2.getId());
fail("Node should not exist, previous tx didn't rollback");
} catch (NotFoundException e) {
// good
}
} finally {
log.setLevel(level);
}
}
Aggregations