Skip to content

Instantly share code, notes, and snippets.

View ldaley's full-sized avatar

Luke Daley ldaley

View GitHub Profile
@ldaley
ldaley / gist:f5b01de44b0bae8d5fd7
Created July 16, 2014 08:36
Bootstrapping an embedded ratpack app
import ratpack.groovy.handling.GroovyChainAction
import ratpack.guice.BindingsSpecAction
import ratpack.guice.Guice
import ratpack.handling.Context
import ratpack.launch.LaunchConfigBuilder
import ratpack.server.BindAddress
import ratpack.server.PublicAddress
import ratpack.server.RatpackServerBuilder
@ldaley
ldaley / gist:1f45f1b95eb83286ea08
Created July 11, 2014 01:54
Unit testing an observable service with Ratpack.
import ratpack.exec.ExecControl
import ratpack.exec.ExecController
import ratpack.launch.LaunchConfigBuilder
import spock.lang.AutoCleanup
import spock.lang.Specification
import spock.util.concurrent.BlockingVariable
import static ratpack.rx.RxRatpack.observeEach
class ExecControlSpec extends Specification {
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileScala'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
@ldaley
ldaley / RatpackServer.groovy
Created December 13, 2013 12:49
Self bootstrapped Ratpack app
import ratpack.launch.LaunchConfigBuilder
import ratpack.server.RatpackServerBuilder
import static ratpack.groovy.Groovy.chain
def launchConfig = LaunchConfigBuilder.
baseDir(new File("some/path")).
port(1234).
build {
chain(it) {
@ldaley
ldaley / gist:7832804
Created December 6, 2013 21:58
Transitive clean task in Gradle
apply plugin: "base"
tasks.all { task ->
task.ext.transitiveClean = {
tasks."clean${task.name.capitalize()}".dependsOn {
depsOf(task).flatten().collect { "clean${it.name.capitalize()}" }
}
}
}
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ldaley
ldaley / gist:6163331
Created August 6, 2013 10:11
Netty trace (2)
Aug 06, 2013 11:10:33 AM io.netty.util.ResourceLeakDetector reportLeak
WARNING: LEAK: ByteBuf was GC'd before being released correctly. The following stack trace shows where the leaked object was created, rather than where you failed to release it.
io.netty.util.ResourceLeakException: io.netty.buffer.CompositeByteBuf@17d936e4
at io.netty.util.ResourceLeakDetector$DefaultResourceLeak.<init>(ResourceLeakDetector.java:174)
at io.netty.util.ResourceLeakDetector.open(ResourceLeakDetector.java:116)
at io.netty.buffer.CompositeByteBuf.<init>(CompositeByteBuf.java:60)
at io.netty.buffer.Unpooled.compositeBuffer(Unpooled.java:353)
at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:138)
at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:50)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)