Timeout in JedisPool definition - redis

While defining a jedisPool object I used the following function and parameters as mentioned here.
public JedisPool(final GenericObjectPoolConfig<Jedis> poolConfig, final String host, int port,
int timeout, final String password, final int database) {
this(poolConfig, host, port, timeout, password, database, null);
}
Everything except for timeout is explanatory. What does timeout stand for?
In the other function definitions, we could find parameters like connectionTimeout, soTimeout, and infiniteSoTimeout. If anyone could direct me to any resources that would be much appreciated. I couldn't find these in the official jedis page.

The single timeout parameter represents same value for both connectionTimeout and soTimeout.
In such case infiniteSoTimeout is defaulted to 0 (zero, representing indefinite time).

Related

What does parameters like timeout, connectionTimeout, soTimeout, and infiniteSoTimeout mean in JedisPool?

While defining a jedisPool object, various functions can be chosen from with varying parameters. I want to know what these parameters
timeout
connectionTimeout
soTimeout
infiniteSoTimeout
mean?
Jedis uses java.net.Socket under the hood. The concerned parameters are all directly related to that Socket. Also, the naming of parameters comes mostly from there.
connectionTimeout - timeout value (in milliseconds) to be used while establishing a socket connection.
soTimeout/socketTimeout - timeout value (in milliseconds) to be used while waiting for a response from Redis server (during a regular command execution)
timeout - this is simply a shortcut to use same value for both connectionTimeout and soTimeout
infiniteSoTimeout/blockingSoTimeout - timeout value (in milliseconds) to be used while waiting for a response from Redis server during a blocking command execution. For example, BLPOP is a blocking command.

Why did this txn not transfer balance, I passed the exact same string same hex as response set in question

I called https://etherscan.io/address/0x0c63bf5f9c1b31bd98eb2995e8ab5ba33fe31d22 contract's Try function by passing the same string which was passed in Start function. I checked hex. Can someone help me why Try function call https://etherscan.io/tx/0x096a060d64d833c55fd83b2ea4ec209578dc3316d863de3a3de63692e8476628
did not initiate balance transfer. Is there something, I am missing
The Quiz is a scam contract
The authors usually use a set of similar names ([a-z]{2}_quiz), but most of them contain the same code and act as a honeypot scam.
Read more about it:
https://medium.com/coinmonks/do-not-be-fooled-by-crypto-quiz-games-f38f72a53c78
https://ethereum.stackexchange.com/questions/62815/trying-to-figure-out-this-2-eth-smart-contract-quiz
How the scam works:
The attacker uses internal call from another contract (that doesn't appear on the honeypot "transactions" or "internal calls" lists) to call the New() function and set the hash to some garbage value.
This garbage value is not the hash of the string passed in the Start() function and most probably not even a hash of any string.
Then publicly calls the Start() function (see transaction), so that it looks like they are setting the hash, but it's not set because of this condition:
if(responseHash==0x0){ // it's not 0x0 anymore
responseHash = keccak256(abi.encode(_response));
question = _question;
}

How to access CAN signals dynamically (by string) in CAPL?

I'm trying to force CAN signals to given values using COM interface of CANalyzer. Since there is no COM method to send CAN messages, I'm implementing a workaround using CAPL:
void SendMySignal(int value) {
message MyMessage msg;
msg.MySignal = value;
output(msg);
}
This works fine, however since MyMessage and MySignal are referenced statically (by name) here, I'll have to implement N functions to be able to send N signals (or an N-way switch statement, etc). Is there a way to avoid the hassle and access signals inside a message by string? Something like this:
void SendSignal(int MessageID, char SignalName, int value)
I'm also open to alternative solutions in case I have missed something in the COM interface. If there is a solution which only works for CANoe, I can ask my boss for a license, but of course I'd prefer to do without.
there is such function, but it is restricted to be used only in test nodes
long setSignal(char signalName[], double aValue);
you can find details in:
CAPL Function Overview » Test Feature Set / Signal Access » SetSignal
Special Use Case: Signal is not known before Measurement Start
and take care about not to send for each signal a new message to avoid bus over-flooding. In my opinion it is a better style to set all signals for whole message and to send it on change only when it is not cyclic. Signal updates in cyclic messages mostly have to be sent in next cycle.

WCF and out parameters

It seems there is restriction in having the number of out parameters in WCF. My service reference only downloads one out parameter.
Example: if the service has the following method:
void methodA(out string param1, out string param2)
then the service reference will only create
methodA(out string param1).
Anyone knows how to solve this?
I don't believe there's a limit to the number of out-parameters.
However, for a method that returns void, the first out-parameter actually becomes the return value of the method in the service reference due to a limitation in WSDL. So I would expect the signature of the method to become string methodA(out string param2).
Not sure of a correct fix, but I would return a list of items and not use out parameters in this situation.

How to return often occurring error in object oriented environment?

assume you have a function that polls some kind of queue and blocks for a certain amount of time. If this time has passed without something showing up on the queue, some indication of the timeout should be delivered to the caller, otherwise the something that showed up should be returned.
Now you could write something like:
class Queue
{
Thing GetThing();
}
and throw an exception in case of a timeout. Or you
write
class Queue
{
int GetThing(Thing& t);
}
and return an error code for success and timeout.
However, drawback of solution 1 is that the on a not so busy queue timeout is not an exceptional case, but rather common. And solution 2 uses return values for errors and ugly syntax, since you can end up with a Thing that contains nothing.
Is there another (smart) solution for that problem? What is the preferred solution in an object oriented environment?
I would use exceptions only when the error is serious enough to stop the execution of the application, or of any big-enough application's component. But I wouldn't use exceptions for common cases, after which we continue the normal execution or execute the same function again. This would be just using exceptions for flow control, which is wrong.
So, I suggest you to either use the second solution that you proposed, or to do the following:
class Queue
{
bool GetThing(Thing& t); // true on success, false on failure
string GetLastError();
};
Of course you can stick with an int for an error code, instead of a string for the full error message. Or even better, just define class Error and have GetLastError() return it.
Why not just return null from GetThing in your first solution, changing it to return a Thing *? It seems to fit the bill, at least from the information you've given so far.
In the first, and second case, you can't do anything but throw an exception. When you return a Thing, or a Thing&, you don't have the option of not returning a Thing.
If you want to fail without using an exception then you need:
class Queue
{
// Either something like this. GetThing retuns NULL on an error,
// GetError returns a specific error code
Thing* GetThing();
int GetError();
// This kind of pattern is common. Return a result code
// and set ppOut to a valid thing or NULL.
int GetThing(Thing** ppOut);
};