The code below is from the book Learning Spring Boot 2.0 by Greg Turnquist. It runs with reactor-core version 3.0.7. It won't compile with version 3.1.0 or later. In 3.0.7 the Mono.just().and() method returns a Mono<reactor.util.function.Tuple2<T, T2>>. In 3.1.0 it returns a Mono<Void>.
This is a really bad, breaking change in a minor revision. What do I need to do to make this code run under 3.1.0 and later?
Flux.just("alpha", "bravo", "charlie")
.map(String::toUpperCase)
.flatMap(s -> Flux.fromArray(s.split("")))
.groupBy(String::toString)
.sort((o1, o2) -> o1.key().compareTo(o2.key()))
.flatMap(group -> Mono.just(group.key()).and(group.count()))
.map(keyAndCount ->
keyAndCount.getT1() + " => " + keyAndCount.getT2())
.subscribe(System.out::println);
I'll post the answer for anyone else who runs into this. Simply replace the call to and() with a call to zipWith():
.flatMap(group -> Mono.just(group.key()).zipWith(group.count()))
It's very strange that the reactor team would make a breaking change in a minor revision.
Related
cable_ready 4.5.0
rails 6.1.4.1
ruby 3.0.2p107
This is a simple example from the basic tutorial (https://www.youtube.com/watch?v=F5hA79vKE_E) I suspect the error I am getting is because either cable_ready or rails evolved a little and created a tiny incompatibility.
I get this error in the JS console:
It is triggered when in my controller I ask cable ready to:
cable_ready["timeline"].console_log(message: "***** cable ready post created")
Which leads to my timeline_channel to:
received(data) {
console.log("******** Received data:", data.operations)
if (data.cableReady) CableReady.perform(data.operations)
}
My interpretation is perform causes this line in cable_ready.js line 13:
operations.forEach(function (operation) {
if (!!operation.batch) batches[operation.batch] = batches[operation.batch] ? ++batches[operation.batch] : 1;
});
Is finding something in the received data that it doesn't like.
That's where my trail ends. Can someone see what I am doing wrong, or tell me what other code you'd like me to include?
Solution: downgrade the version of the cable_ready javascript library.
I previously (maybe a year ago) did this tutorial using CableReady 4.5, Ruby 2.6.5 and Rails 6.0.4 and it worked like a charm back then as well as today.
But today, I tried this tutorial again on a duplicate project--same versions of CR, Ruby, and Rails and now I get java console errors similar to yours.
TypeError: undefined is not a function (near '...operations.forEach...')
perform -- cable_ready.js:13
received -- progress_bar_channel.js:8
I looked at the output of yarn list and saw that cable_ready was version 5.0.0-pre8 on the bad project and it was 5.0.0-pre1 on the good project. The downgrade could be accomplished with yarn add cable_ready#^5.0.0-pre1 in the bad project folder and now both projects work.
FYI for other newbies like me trying to understand how CableReady works: This tutorial gives another example of CableReady, and was also fixed the same way.
The Cypher generated by spring data neo4j uses "$" to pass value, which will cause a error of Invalid Syntax by neo4j.
For example:
The Cypher generated by spring data neo4j for:
Optional<linkType> findById(Long id);
is
"MATCH ()-[r0:`linkType`]->() WHERE ID(r0)=$id WITH r0,STARTNODE(r0) AS n, ENDNODE(r0) AS m RETURN r0,n,m, ID(r0)"
This gets a error of Invalid Syntax.
I fixed this by use #Query:
#Query("MATCH ()-[r0:`linkType`]->() WHERE ID(r0)={id} WITH r0,STARTNODE(r0) AS n, ENDNODE(r0) AS m RETURN r0,n,m, ID(r0)")
Optional<linkType> findById(Long id);
However, when I want to use the PagingAndSortingRepository, I cannot use the #Query to fix this problem. Because it will add SKIP $sdnSkip LIMIT $sdnLimit at the edn automaticaly.
How can I fix this problem? Thanks.
You are using a really old version of neo4j (older than 3.0).
In neo4j 3.0, the {foo} syntax was deprecated in favor of the $foo syntax. In neo4j 4.0, the {foo} syntax was totally removed.
Instead of trying to support the obsolete {foo} syntax, you should upgrade your neo4j installation to a more recent (ideally, the latest) version of neo4j. If you have data to upgrade, you will have to upgrade in 2 steps:
From your current version to 3.5.
From 3.5 to 4.x.
Trying MockWebServer for the first time on a Groovy/Spring project that uses Spock for unit testing.
I added MockWebServer dependencies as directed (I had to add the second line myself to avoid errors, but it's not documented:
testImplementation("com.squareup.okhttp3:mockwebserver:4.0.0")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.40")
I have a basic Spock test that looks like this:
def 'server'() {
setup:
MockWebServer server = new MockWebServer()
expect:
server
}
But it fails with this output:
java.lang.NoSuchMethodError: okhttp3.internal.Util.immutableListOf([Ljava/lang/Object;)Ljava/util/List;
at okhttp3.mockwebserver.MockWebServer.<init>(MockWebServer.kt:176)
Is there another dependency I'm missing? Does MockWebServer not play well with Groovy and Spock?
For what it's worth, using version 3.1.4 seems to work:
testImplementation("com.squareup.okhttp3:mockwebserver:3.14.2")
(I'm a first time user of MockWebServer)
Thank you!
Try adding this:
testImplementation("com.squareup.okhttp3:mockwebserver:4.0.0")
testImplementation("com.squareup.okhttp3:okhttp:4.0.0")
With MockWebServer your OkHttp dependency must be the same version.
I got the same problem, I found the solution in version, just change the version to "3.7.0" and it's work fine.
there is some discussion about version changing to "3.4.1" but this version got the problem (Cannot inherit from final class) that discussed at this issue :
https://github.com/andrzejchm/RESTMock/issues/56
so the safest version is "3.7.0" :D
just notice that both versions should be the same..
change your to dependencies to below:
//mock retrofit
testImplementation("com.squareup.okhttp3:mockwebserver:3.7.0")
testImplementation("com.squareup.okhttp3:okhttp:3.7.0")
//if your source code is java
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.40")
I've been trying to get Jung 2.1.1 to work successfully but whatever breaking changes were made are just not making sense.
After importing the 2.1.1 jars, I get the error:
The constructor VisualizationViewer(Network, LayoutAlgorithm, Dimension) is undefined
for the line:
VisualizationViewer vv = new
VisualizationViewer(g, layoutAlgorithm, new Dimension(900, 900));
where
Network g = NetworkBuilder.undirected().build(); // and other load steps
There are other imports that aren't working, like
import edu.uci.ics.jung.visualization.decorators.PickableNodePaintFunction;
import edu.uci.ics.jung.visualization.layout.LayoutAlgorithmTransition;
Edit: It appears the classes in the Jung 2.1.1 JAR still use the old definitions, for example
VisualizationViewer(Layout<V,E>,Dimension)
and not
VisualizationViewer(Network<N,E>,Dimension,Dimension)
This question was answered in https://github.com/jrtom/jung/issues/201
The short version is that you should not be cloning the HEAD version on the JUNG website; that's the 3.0 version in development, which is not yet ready for release, and is incompatible with 2.1.1. Use the 2.1.1 version explicitly for both the jars and the samples.
I am running neo4j enterprise 1.8 on grails and wanted to upgrade to 1.8.1. As I am also using the Cypher Engine extensively, after upgrade I tried to execute some queries. Unfortunately I encountered an Exception when trying to initiate the Cypher ExecutionEngine.
I've written a small Service which does the work for me:
import org.neo4j.cypher.javacompat.ExecutionEngine
import org.neo4j.kernel.impl.util.StringLogger
class CypherService {
def graphDatabaseService
static transactional = true
def executeString(String cypherString) {
log.debug "start method executeString"
ExecutionEngine executionEngine = new ExecutionEngine(graphDatabaseService, StringLogger.DEV_NULL)
if(executionEngine) {
def result = executionEngine.execute(cypherString)
return result
} else {
log.error "Could not initialize the execution engine for Cypher"
return null
}
}
}
When initiating the Execution Engine, I got the following Exception:
java.lang.NoSuchMethodError: com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder.maximumWeightedCapacity(J)Lcom/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder;
at org.neo4j.cypher.internal.LRUCache.<init>(LRUCache.scala:31)
at org.neo4j.cypher.ExecutionEngine$$anon$1.<init>(ExecutionEngine.scala:91)
at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:91)
at org.neo4j.cypher.javacompat.ExecutionEngine.<init>(ExecutionEngine.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202)
at com.netjay.fanorakel.CypherService.executeString(CypherService.groovy:16)
Any idea what is going wrong here, and is there a solution to avoid this?
Best
Michael
You could probably also just rebuild Neo4j's cypher module against the older version of the lib, or actually exclude the dependency from neo4j.
I had the same issue- with 1.8.1 I needed to separately include concurrentlinkedhashmap-lru.1.3.1.jar
http://code.google.com/p/concurrentlinkedhashmap/downloads/detail?name=concurrentlinkedhashmap-lru-1.3.1.jar&can=2&q=
The problem here is that:
Neo4j 1.8.1 introduced a new dependency to concurrentlinkedhashmap_lru version 1.3.1, AND
Grails has a dependency to concurrentlinkedhashmap_lru version 1.2_jdk5, AND
concurrentlinkedhashmap_lru's API is not backwards compatible for these two versions.
Therefore the grails codebase has been recently upgraded to move the dependency to 1.3.1, see https://github.com/SpringSource/grails-data-mapping/commit/b15e207a2a08ac16e77de399733cb9cc14eff48e and
https://github.com/grails/grails-core/commit/6dfab1a5db4da8c176351f23d65c7fc0d4aa6364.
So to use Neo4j 1.8.1 (and newer) with Grails you could either wait for a new Grails release or build a Grails snaptshot on your own.