Skip to content

Instantly share code, notes, and snippets.

View ldaley's full-sized avatar

Luke Daley ldaley

View GitHub Profile
@ldaley
ldaley / gist:6163301
Created August 6, 2013 10:03
Netty stack trace.
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:218)
at sun.nio.ch.IOUtil.read(IOUtil.java:186)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359)
at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:275)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:867)
at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:227)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:87)
tomcatRun {
gradle.taskGraph.whenReady {
if (it.hasTask(test)) {
daemon = true
}
}
}
test {
dependsOn tomcatRun
task assembleAllAsciidoc(type: Copy) {
into "$buildDir/asciidoc"
allprojects {
from project.asciidoc // assuming the asciidoc task correctly declares its outputs
into project.name // subdir is the name of the project
}
}
import static org.ratpackframework.groovy.RatpackScript.ratpack
ratpack {
handlers {
handler {
if (request.path.empty || request.path == "index.html") {
response.addHeader "X-UA-Compatible", "IE=edge,chrome=1"
}
next()
}
public String getBindHost() {
if (boundAddress == null) {
return null;
} else {
InetAddress address = boundAddress.getAddress();
if (address.isAnyLocalAddress()) {
return "localhost";
} else {
return address.getHostAddress();
}
def "can handle errors on forked threads"() {
given:
def errorHandler = new ErrorHandlingContext() {
void error(Exchange exchange, Exception exception) {
exchange.response.send("Caught: $exception.message")
}
}
when:
app {
@ldaley
ldaley / gist:5559921
Created May 11, 2013 13:09
New capability in Gradle 1.6. Run all verifications (e.g. checkstyle, tests) on all projects (if they are to be executed in this build) before uploading anything. e.g. ./gradlew clean build uploadArchives Will only upload after all projects have been built and tested.
allprojects {
tasks.withType(Upload) {
allprojects {
mustRunAfter tasks.matching { it instanceof VerificationTask }
}
}
}
@ldaley
ldaley / gist:5429603
Last active March 5, 2018 14:59
Groovy @DelegatesTo and type tokens.
Handler<T> handler(@DelegatesTo.Target(asType = true) Class<T> type, @DelegatesTo Closure<?> configurer) {
return new Handler() {
void handle(T object) {
configurer.delegate = object
configure.call(delegate)
}
}
}
@ldaley
ldaley / functional-test.gradle
Created February 22, 2013 11:29
funtional testing config
sourceSets {
functionalTest {
task functionalTest(type: Test) {
testClassesDir = output.classesDir
testSrcDirs = java.srcDirs.toList()
classpath = runtimeClasspath
}
}
}