This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Thunk<T> { | |
private volatile T value; | |
private final Provider<T> provider; | |
public Thunk(Provider<T> provider) { | |
this.provider = provider; | |
} | |
/** | |
* Data race is possible here: there can be multiple invocations of creator func |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ExecutorService s = Executors.newFixedThreadPool(10); | |
Future<?> f = s.submit( | |
new Runnable() { | |
@Override | |
public void run() { | |
try { | |
Context.enter(); | |
// do stuff | |
} catch (Throwable e) { | |
} finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FSBridgeClientException extends RuntimeException { | |
private final FSBridgeClientError error; | |
public FSBridgeClientException(Throwable e, FSBridgeClientError error) { | |
super(e); | |
this.error = error; | |
} | |
public FSBridgeClientException(FSBridgeClientError error) { | |
this.error = error; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JsonDecoder<Map<String, Object>> jsonDecoder = getInstance( | |
Key.<JsonDecoder<Map<String, Object>>>get(new TypeLiteral<JsonDecoder<Map<String, Object>>>(){}) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: key=value] | |
at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1212)[camel-core-2.9.0.jar:2.9.0] | |
at org.apache.camel.builder.ExpressionBuilder$33.evaluate(ExpressionBuilder.java:815)[camel-core-2.9.0.jar:2.9.0] | |
at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[camel-core-2.9.0.jar:2.9.0] | |
at org.apache.camel.component.bean.MethodInfo$2.evaluateParameterBinding(MethodInfo.java:507)[camel-core-2.9.0.jar:2.9.0] | |
at org.apache.camel.component.bean.MethodInfo$2.evaluate(MethodInfo.java:406)[camel-core-2.9.0.jar:2.9.0] | |
at org.apache.camel.component.bean.MethodInfo.createMethodInvocation(MethodInfo.java:209)[camel-core-2.9.0.jar:2.9.0] | |
at org.apache.camel.component.bean.BeanInfo.createInvocation(BeanInfo.java:207)[file:/home/dgabaydulin/work/jpush/jpush/target/classes/:2.9.0] | |
at org.apache.camel.component.bean.BeanProcessor.process(Bean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<String, List<ConfigParameter>> parameterNameToValuesList = Maps.newHashMap(); | |
for (ConfigParameter parameter : parameters) { | |
String name = parameter.getParamName(); | |
if (!parameterNameToValuesList.containsKey(name)) { | |
parameterNameToValuesList.put(name, Lists.<ConfigParameter>newArrayList()); | |
} | |
parameterNameToValuesList.get(name).add(parameter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
merge /*+ index(e ext_val_pk6) use_nl(e) string*/ | |
into ext_values e | |
using (select ? txn_id, ? exn_id, ? ext_value from fastdual) d | |
on (e.txn_id = d.txn_id and e.exn_id = d.exn_id) | |
when matched then update set ext_value = d.ext_value | |
when not matched then insert (txn_id, exn_id, ext_value) values (d.txn_id, d.exn_id, d.ext_value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resultCheckerExecutor.execute( | |
new Runnable() { | |
@Override | |
public void run() { | |
while (true) { | |
try { | |
Task saved = taskDao.getById(task.getId()); | |
assertNotNull(saved); | |
if (saved.getState().equals(TaskState.ERROR)) { | |
assertNull(saved.getFinished()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @see <a href="http://en.wikipedia.org/wiki/Eulerian_path">Eulerian Path</a> | |
*/ | |
public class EulerianPath { | |
private final Logger log = Logger.getLogger(EulerianPath.class); | |
private final Graph graph; | |
public EulerianPath(Graph graph) { | |
this.graph = graph; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IntervalTree<Integer, Range<Integer>> probabilitiesToRanges = new IntervalTree<Integer, Range<Integer>>( | |
Arrays.<RangeWithValue<Integer, Range<Integer>>>asList( | |
new RangeWithValue<Integer, Range<Integer>>(1, 500, new Range<Integer>(1, 500)), | |
new RangeWithValue<Integer, Range<Integer>>(501, 551, new Range<Integer>(501, 1000)), | |
new RangeWithValue<Integer, Range<Integer>>(552, 592, new Range<Integer>(1001, 1000)), | |
new RangeWithValue<Integer, Range<Integer>>(593, 613, new Range<Integer>(2001, 5000)), | |
new RangeWithValue<Integer, Range<Integer>>(614, 624, new Range<Integer>(5001, 10000)), | |
new RangeWithValue<Integer, Range<Integer>>(625, 625, new Range<Integer>(10001, 100000)) | |
) | |
); |
NewerOlder