question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Guava 23 `edgeValueOrDefault` missing edge returns non-default value

See original GitHub issue

In Guava 23…

Assume nodeA exists but #nodeU does not exist. Execute:

graph.edgeValueOrDefault(nodeA, nodeU, 5)

The result is null. I would expect the result to be 5, given that there is no edge between nodeA and non-existent nodeU. Guava 22 an earlier have the expected behavior.

I see that Guava 23 now returns an Optional for edgeValue, so the statement can easily be converted to graph.edgeValue(nodeA, nodeU, 5).orElse(5), however if this is the intended behavior of the edgeValueOrDefault method for this situation, it deserves some additional explanation in the Javadoc. Or simply deprecate this method and recommend people transition to edgeValue().orElse().

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jrtomcommented, Oct 5, 2017

Fixed (see above commit). Thanks, @rocketraman.

0reactions
jrtomcommented, Oct 4, 2017

Somehow I completely failed to notice this issue previously; my apologies.

The behavior of edgeValueOrDefault() wasn’t intended to change from 22.0 to 23.0; I introduced a regression when doing some internal refactoring that apparently wasn’t caught by our tests. Sorry about that.

I’ll get a fix out for that as soon as I can.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueGraph (Guava: Google Core Libraries for Java 22.0 API)
An interface for graph-structured data, whose edges have associated non-unique values. A graph is composed of a set of nodes and a set...
Read more >
com.google.common.graph.ValueGraph.edgeValueOrDefault ...
Returns the value of the edge that connects endpoints (in the order, if any, specified by endpoints), if one is present; otherwise, returns...
Read more >
Network (Guava: Google Core Libraries for Java 22.0 API)
An interface for graph-structured data, whose edges are unique objects. ... Returns the edges whose incident nodes in this network include node ....
Read more >
Graphs (Guava: Google Core Libraries for Java 20.0 API)
Returns true if graph has at least one cycle. A cycle is defined as a non-empty subset of edges in a graph arranged...
Read more >
graph api in guava 20.0 does not include edge as an object
As you can see, edge in a graph is an EndpointPair of two nodes. Internal data structure for this edge contains start node...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found