How to distinguish connect-timeout and socket-timeout in ZuulFallbackProvider? - spring-cloud

I am using ZuulFallbackProvider to handle fallback and would like to know how to distinguish one root cause from another, such as connect-timeout and socket-timeout. However, I am unable to find a lead by only examing the RequestContext in getBody(). Any advice is appreciated.
I also left the same question on git:
https://github.com/spring-cloud/spring-cloud-netflix/issues/2347

In Edgware (as of yet unreleased) the new FallbackProvider provides fallbackResponse(Throwable cause). You should be able to inspect the cause to find out.

Related

Python stacktrace without sitepackages?

I was wondering if there is a way to get a 'simplified' version of the exception stacktrace.
one that does not contain the trace of functions that are sourced in outside site-packages.
kind of like Justmycode. but for python with pycharm..
I have tried looking around but haven't found anything yet,
i'm aware that I can take the Stacktrace and filter out rows that are from outside sources,
but I really thought there would already be a solution for it?
Thanks in advance!
The tbvaccine Python package shows relevant lines highlighted, which is like a visual filter of irrelevant lines.
The package doesn't seem to be under active development btw.

Cache2k: java.lang.UnsupportedOperationException: loader not set

Cache2k looks like a very promising caching implementation. Unfortunately the documentation is very limited, which is why I need some help with the following issue. I am using the latest version 0.26-BETA.
According to the documentation the cache is supposed to be created like this:
Cache<String,String> c =
CacheBuilder.newCache(String.class, String.class).build();
String val = c.peek("something");
assertNull(val);
c.put("something", "hello");
val = c.get("something");
assertNotNull(val);
c.destroy();
Unfortunately at least 2 of these methods are deprecated, including the CacheBuilder class itself. I therefore tried creating the cache like this:
org.cache2k.Cache<String, Object> newCache = Cache2kBuilder.of(String.class, Object.class)
.name(cacheKey.toString())
.entryCapacity(100000)
.eternal(true)
.build();
This however throws the "java.lang.UnsupportedOperationException: loader not set" exception.
The question therefore is: how am I supposed to build the cache so that I do not get this exception?
EDIT:
This gives me the same exception:
org.cache2k.Cache<Object, Object> newCache =
CacheBuilder.newCache(Object.class, Object.class)
.eternal(true)
.build();
EDIT #2:
Just one more note: When I copy&paste the code from the wiki page I get an error - as can be seen in the image below.
With what jdk version are you testing? I'll try just removing the <> that are causing the problem for now.
Thanks very much in advance!
Michael
Cache2k looks like a very promising caching implementation.
Thanks :)
According to the documentation the cache is supposed to be created like this
There are new interfaces in place. The deprecated one is still there to support users of old cache2k versions. That will get cleared up in the next weeks. Sorry for the confusion.
Please take a look here for the latest getting started information:
https://github.com/cache2k/cache2k/blob/master/doc/src/docs/asciidoc/user-guide/sections/_start.adoc
This however throws the "java.lang.UnsupportedOperationException: loader not set" exception.
The question therefore is: how am I supposed to build the cache so that I do not get this exception?
Short answer: Either use cache.peek() or wait for 0.27, since then it is working with cache.get() transparently.
Longer answer: In our own applications I use cache.get() only when a loader is defined and cache.peek() when no loader is defined or when I want to inspect the cache only. Reserving cache.get() only for the read through usage, seemed like a good idea. However, I reasoned that it might be a caveat for new users, so I change that behavior and align it to other cache solutions.
Answer to Edit 2:
For an untyped cache use the factory method Cache2kBuilder.forUnkownTypes(). Constructing the anonymous class is only needed for specific types.

With Buildbot Source Step: why can 'codebase' not be set via Interpolate while 'repourl' can?

I have a factory that I use in several builders and I set builder specific settings via util.Property and util.Interpolate. While this works fine for repourl and branch it simply doesn't work for codebase. The following piece of code shows the source step how I would like to use it in my Buildbot configuration.
factory.addStep(
steps.Git(repourl=util.Interpolate('git://repo_base_path/%(prop:build_repository)s', default=''),
branch=util.Property('build_branch', default='master'),
mode='full',
codebase=util.Interpolate('%(prop:build_repository)s', default=''),
method='copy', submodules=True, clobberOnFailure=True)
)
)
Without the codebase part all worked fine. I then figured I would need to set the codebase for some cases so I added the codebase line, resulting in the following error:
[-] Configuration Errors:
[-] error while parsing config file: sequence item 1: expected
string, Interpolate found traceback in logfile
Does anybody know why it is not possible to set the codebase via Interpolate while it is no problem to do the same thing with repourl?
Does somebody have an idea how to set the codebase for the source step to something different from '' and still not create a separate factory instance for every builder?
Any insights into this and any helpful suggestion is highly appreciated.
I think this is a bug in Buildbot. Looking at the Buildbot 0.8.12 sources, I can see that in buildbot/steps/source/git.py, in class Git, the renderables attribute includes "codebase", which should mean that you can use Interpolate in this way. Presumably some other code is assuming it can interpret codebase as a string at the time the configuration is parsed.
In other words, as far as I can tell, you're doing something that the Git class claims to support.
It looks like the old-style Git support in buildbot/steps/source/oldsource.py doesn't support codebase being a renderable, but it doesn't look to me like you're using that. I'm not entire sure, though, because I'm not sure what steps.Git refers to.

Clone a Gtk.Button from gjs

How would I go about cloning any widget from gjs, similar to the C response given in https://stackoverflow.com/a/3030603/1829961? I have not been able to find a way to call list_properties although it is listed in the GModule gir file. Or do I have to use GIRepository, manually walk the GIR type hierarchy, emulating that which g_object_class_list_properties is supposed to do? Or another straight forward way I'm totally missing here?
Here is some code that will do that.
It takes a similar approach to the quesion you linked, but since there is no G_OBJECT_GET_CLASS() in GJS, it uses GIRepository instead -- which is an extra dependency that you need compared to the C solution.

Autofac component registration/resolution bug?

I seem to have a problem - rather unexpected; so I guess I might be doing something silly/wrong.
I register two container scoped services as such:
builder.Register<IServiceInfo>(c => CreateServiceInfo(c)).As<IServiceInfo>();
builder.Register<IServiceInfo>(c => CreateServiceInfoSomeOther(c)).As<IServiceInfo>().Named("someOther");
Now when I try to resolve
container.Resolve<IServiceInfo>()
and container.Resolve<IServiceInfo>("someOther")
I get the same instance. I would expect the first call to return the first instance and the second call to return the second instance. Why is this happening this way?
I am hoping there are some active Autofac experts around here and I'd appreciate any help to quickly fix this.
Thanks, all!
When two services are registered, the last one wins (it doesn't matter that the second is named, it's still a registration for that service), unless you ask for an instance by name.
You can use ".DefaultOnly()" to modify your second registration so that the first is the actual default. See the wiki page for more info.