Skip to content

Instantly share code, notes, and snippets.

@jentfoo
jentfoo / ILockWrapper
Created May 31, 2013 19:55
Wrapper for hazelcast lock to work around issue #267
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import com.hazelcast.core.ILock;
public class ILockWrapper implements Lock {
private static final Map<String, Object> LOCK_THREAD_LOCKS = new HashMap<String, Object>();
@jentfoo
jentfoo / AlternatorFailure
Created July 20, 2015 22:34
Failure repo code for Alternator issue #94
package crab.db;
import java.util.Iterator;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Item;
@jentfoo
jentfoo / gist:4042262f55362bebb276
Created July 29, 2015 23:29
aws-sdk-java PR #459 alternative
diff --git a/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/MessageMD5ChecksumHandler.java b/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/MessageMD5ChecksumHandler.java
index 3d02445..8d84a39 100644
--- a/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/MessageMD5ChecksumHandler.java
+++ b/aws-java-sdk-sqs/src/main/java/com/amazonaws/services/sqs/MessageMD5ChecksumHandler.java
@@ -278,12 +278,10 @@ public class MessageMD5ChecksumHandler extends AbstractRequestHandler {
* input ByteBuffer and all the bytes it contains.
*/
private static void updateLengthAndBytes(MessageDigest digest, ByteBuffer binaryValue) {
- // Rewind the ByteBuffer, in case that get/put operations were applied to
- // the unmarshalled BB before it's passed to this handler.
@jentfoo
jentfoo / gist:742806ef3c5395e910ea
Created December 4, 2015 21:45
threadly schedule 4.4.0 regression unit test
@Test
public void scheduleLaterThenSoonerTest() {
// This test is focused around the scheduling defect fixed in 4.4.1
// The condition hit was where we would park for one scheduled task, then a future task
// would not get executed in time because the first parked thread was not woken up
final PriorityScheduler scheduler = new PriorityScheduler(2);
try {
// schedule one task a ways out
scheduler.schedule(DoNothingRunnable.instance(), 1000 * 60 * 10);
@jentfoo
jentfoo / DosParallismControlFilter.java
Created March 2, 2016 15:47
Example non-blocking jetty parallism filter
package com.fullcontact.load.sandbox;
import java.io.IOException;
import java.util.concurrent.Executor;
import javax.servlet.AsyncContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
@jentfoo
jentfoo / ThreadlyTicker.java
Created May 10, 2016 19:34
Threadly guava ticker
import org.threadly.util.Clock;
import com.google.common.base.Ticker;
/**
* Adapter between guava's {@link Ticker} and threadly's {@link Clock}.
*/
public class ThreadlyTicker extends Ticker {
public static final ThreadlyTicker INSTANCE = new ThreadlyTicker();

Keybase proof

I hereby claim:

  • I am jentfoo on github.
  • I am jent (https://keybase.io/jent) on keybase.
  • I have a public key ASCXF5qQHh2ufnmYue-DjIMK3kSK2nGxCjzWjf05h-tQWwo

To claim this, I am signing this object: