infinite loop detected, partial ../foo.mustache was previously loaded - java

Hi I have two handlebars templates which is as below.
foo.mustache
{{#if hasProperties}}
{{>bar}}
{{/if}}{{^hasProperties}}{{propsName}}{{/hasProperties}}
bar.mustache
{{#propertyObject}}{{>foo}}{{/propertyObject}}
When I compile this and run, I get the following error.
infinite loop detected, partial '/templates/foo.mustache' was
previously loaded
What is the proper way to fix this?

I've found the solution for this issue. It's not something related to the template itself. The mustache files were in correct order but there is a property in the mustache java implementation where default value is set to false.
public void setInfiniteLoops(boolean infiniteLoops) link
this method will actually set to accept infinite loops which will be needed if you are running a recursive call inside the mustache template itself.
I hope this will help anyone looking to solve a similar kind of error.

Related

How to create your own Live Template, using the current line (Intellij)

I am trying to create my own live template which uses the current line that my cursor is on, but I cannot find the variable for it.
To explain what I mean, IntelliJ has a built-in .sout template which SOUTs the current statement.
I am trying to find a way to add my own .[extention] that wraps the current code on that line, into a different statement.
So something like this:
Will turn into this:
Any ideas on how to get that done properly?
You need to create postfix completion. Rather than Live template, postfix completion surrounds an expression you’ve just typed.
See https://www.jetbrains.com/help/idea/settings-postfix-completion.html

Oracle-UCM service CHECKIN_UNIVERSAL is throwing errors when trying to checkin an existing file

I'm working on Java code that checks whether a file exists in the system and whether it's checked out. After these checks it calls the CHECKIN_UNIVERSAL service. This is where it stops. Checking in a new file works just fine, but it's the checking in of an existing file that's giving errors.
The specific error displayed (without making modifications to my original code) is !cscheckinitemexists. A bunch of googling turned up the solution to clear the data binder, yet then it comes up with the error that it cannot retrieve or use the security token.
Here's the code I use to clear and retrieve the data binder:
m_binder.clearResultSets();
m_binder.getLocalData().clear();
m_binder.setEnvironment(new IdcProperties(SharedObjects.getSecureEnvironment()));
What does the rest of your code look like? You can link to a Gist.
Generally, I have run into this due to data pollution (as you stated).
Is there a reason you are using m_binder instead of creating a brand new DataBinder?
After looking at your gist, you are using m_binder (the DataBinder from the service) to execute CHECKIN_UNIVERSAL. Don't do this. Use a separate DataBinder (as you did for the DOC_INFO_BY_NAME service call).
Either use requestBinder or a new DataBinder.
Another way to avoid this issue is to simply not look for the checkout. CHECKIN_UNIVERSAL supports a flag that checks out a content item if it's not already checked out.
Add the flag "isForceCheckout" to your binder, with a value of "1".

RSyntaxTextArea Custom Language JFlex

I'm trying to use JFlex to add custom language highlighting to RSyntaxTextArea. However, the moment I type a character I get an Index Out of Bounds Exception:
http://pastie.org/private/ygjyj4y5nludeu3dn1xug
This occurs even if I use the example JFlex code provided here: https://github.com/bobbylight/RSyntaxTextArea/wiki/Adding-Syntax-Highlighting-for-a-new-Language
I'm not sure what could be causing this. Could someone point me in the right direction?
I'm not quite sure why this works, but I appear to have fixed this problem by copying part of the yylex method from PythonTokenMaker.java to the Java class created by JFlex.
Specifically, I copied and replaced this section of the code: http://pastie.org/private/whjzfhbrzwm8qc88t1idq
It is from the defintion of the method to the line with the comment // store back cached position
Hopefully this will help someone stuck on the same problem!

How to closely monitor a java.util.map for certain insertions

I have a problem debugging someone else's Java code in Eclipse and I have narrowed the problem down to a certain entry in a java.util.Map. At some stage, a certain key is put into the map, which is causing the problem. I have already checked all "put()" and "putAll()" calls to this map object, but haven't found the location at which the erroneous entry is created.
So, the question is: How can I monitor this Map object for insertions of a certain key? Basically, I would like the code execution to stop whenever key x is inserted or updated on this map. Is this possible?
Cheers,
Martin
In Eclipse you can create a conditional breakpoint. This breakpoint will only trigger when your specified condition takes place. This will allow you to monitor the put methods on the map.
Step 1: Select the breakpoint properties after right clicking on your breakpoint:
Step 2: Select the conditional checkbox and enter your condition:
Step 3: Run your app in debug mode.
Who does instantiate the map? If you can set it, then provide your custom implementation that throws exception if the searched value is passed. And then you will see in stacktrace, who and when insert this value.
After speaking to one of our seniors guys, it turns out the problem was not so much the Map, bur rather an underlying XML structure that is used to populate the map. Looks like I was following a red herring. Nevertheless, thanks a lot to everyone who replied!

Dll function returns 1

Im using Java (JNA) to use a function in a third party .dll file. The functions I'm calling are returing the integer value 1.
After reading, I've discovered that this return value is traditionally 0 if everything runs correctly.
Was wondering if this is always the case or if theres any way to determine what it should be?
In the .h file bundled with the .dll it has the comment
// rc: EXIT_SUCCESS means NO ERROR
After the function.
Check actual dll documentation, there should be the way to tell what's wrong.
If nothing helps try calling GetLastError() WinAPI - some meaningful error code might be reported.
Also try to look at debug output during function call - some traces might be there even in Release build
Yes, zero typically means success in the C/C++ world.
In the days before exception handling you had to have a way to indicate failure and the return value was pretty much reserved for failure/success. As for what '1' means, you will have to look in the header of the dll for the function that is returning '1' and see if they included anything about error conditions. There are too many possibilities without seeing the code or knowing more about the dll to provide any easy answers.
What is the name of the function? What is it attempting to do? What can you do if you know the function failed?

Categories

Resources