hubspot / algebra Goto Github PK
View Code? Open in Web Editor NEWSimple abstract data types (wrapping derive4j) in Java
License: Apache License 2.0
Simple abstract data types (wrapping derive4j) in Java
License: Apache License 2.0
Currently, when handed a result that isn't valid JSON, the ResultDeserializer will throw a NullPointerException
. Can that please be changed to fail more gracefully?
java.lang.NullPointerException: null
at com.hubspot.algebra.ResultDeserializer.deserialize(ResultDeserializer.java:33)
at com.hubspot.algebra.ResultDeserializer.deserialize(ResultDeserializer.java:17)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3807)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2874)
at com.hubspot.connect.http.AbstractHttpResponse.getAs(AbstractHttpResponse.java:75)
at com.hubspot.engagements.emails.client.EngagementsEmailClient.createEmailEngagement(EngagementsEmailClient.java:48)
at com.hubspot.engagements.emails.data.FacsimileEmailSendingManager.createEngagement(FacsimileEmailSendingManager.java:277)
at com.hubspot.engagements.emails.data.FacsimileEmailSendingManager.scheduleEmail(FacsimileEmailSendingManager.java:223)
at com.hubspot.engagements.emails.data.FacsimileEmailSendingManager.scheduleEmail(FacsimileEmailSendingManager.java:167)
at com.hubspot.engagements.emails.service.resources.SendEmailResource.scheduleEmail(SendEmailResource.java:89)
at com.yammer.metrics.guice.TimedInterceptor.lambda$forMethodSync$0(TimedInterceptor.java:42)
at sun.reflect.GeneratedMethodAccessor392.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:205)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
Same with VoidResult.
I'm unwrapping a result, which is inside a generically typed method. If the type is a Void, which gets wrapped in a result and then extracted it'd be nice to extract the null right back out, instead of failing.
If it has to fail, I think it'd be better to fail early, inside Result.ok(null).
The generated equals function looks like
public boolean equals(Object obj) {
return (obj instanceof VoidResult) && ((VoidResult<ERROR_TYPE>) obj).match((err) -> false,
(ok) -> this.ok.equals(ok));
}
we should try to override this to handle null
better.
Currently, I have implemented a These
type in Java, and believe it could be useful to include it in algebra
library.
Idea comes from: https://hackage.haskell.org/package/these
@stevegutz If you find it useful, I can open a PR here to make a change.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.