Gabriel Rossetti opened 10 years ago
|
|
Wait until tomorrow pls, it has a bug, I will correct tomorrow, thx |
|
Ok, sorry about that, I wrote that a bit quick, I introduced the opposite issue :-). Here is the version I propose, it works with non-array objects, primitive and object arrays:
|
|
Thank you for your bug report. Unfortunately I do not understand the problem. Why do you think there is a bug in the Tigase code? What part of the Tigase code does not work correctly and how the problem manifest itself? The method you mentioning has been working for years and we have never seen any problems with the current implementation. |
|
Artur Hefczyc wrote:
Hi Artur, If you define a property that is an array of a type that has both a primitive and an object representation (e.g. int[] / Integer[]) and you use the object variant instead of the primitive variant (e.g. Integer[]) then I believe it should not for, consistancy, and you should be able to use either the object or primitive types for arrays, just as you can for non-array types (boolean / Boolean; see examples here: http://docs.tigase.org/tigase-server/5.2.2/dev_guide/html/#cil2). To illustrate:
Using this code, when This is also a code bug and not just a philosophical issue because if you look in the
|
|
Performance and resources usage reducing motivated many of our decision on how to design and implement certain parts of the code. Therefore, reason why this method accepts arrays with only primitive types is performance and memory preservation. So this is not really a bug but intentional decision. So this is how it works. I appreciate your explanation and I generally agree with the idea to make the code more flexible and allow it to handle more use-cases but in case of Tigase serve I prefer to push towards more efficient data types. |
|
Artur Hefczyc wrote:
Ok, I can understand if it is by design for performance issues, but then in this case remove the code in
since it doesn't make sense to have those there if they re not supported (it only adds confusion). Also you should mention in the docs that for arrays for types that have a primitive equivalent that you only support arrays of primitives. As a side note, not sure if this is by design too but your code, at least |
|
Ok, I looked at your code and our code and on the second thought, I think it actually makes sense to add your suggestions to the Tigase code and make the method more flexible. |
|
Artur Hefczyc wrote:
Ok, great, thx. |
|
OK, one more question/concern - what about reading preferences from file (and counterpart of that - dumping settings) - how should we treat [i] - as array of |
|
Wojciech, I think we should only change the code which "exports" variables to String as indicated in the original post. This method is used for dumping config to file as far as I remember. I do not want to alter logic which is reading preferences from a config file. |
|
But imagine following configuration:
We can assume this will be int array and as such should be handled in the component (as it's done right now). Now following cases:
|
|
We use, everywhere in our code arrays of int for the configuration and this is how are API works and this is what our code expects. So, I do not think this is a problem that somebody want to use arrays of Integers instead. This is his worry how to load the property correctly. As long as our API is consistent and gives predictable results it is OK. |
|
I've applied the patch. On comment though. Artur Hefczyc wrote:
OK, my previous comment implied that reading property from file is also somehow part of an "API" and if we allow to use object arrays in |
|
No feedback, I am assuming it is working OK now. Closing. |
Type |
Bug
|
Priority |
Normal
|
Assignee | |
RedmineID |
3034
|
Version |
tigase-server-7.1.0
|
Spent time |
13h 30m
|
Hi,
I'm having an issue with integer array server parameters. I traces it down to tigase.util.DataTypes.valueToString(Object), it tries to cast an Integer[] to int[]. Why are you casting to primitives? I am a bit surprised this has never come up before, it should happen with all arrays that are cast to a primitive array. I'm using Java 7 BTW on Tigase 5.x, I checked the master branch and it is the same as in the 5.x branchs.
I can suggest two implementations, one based on yours (with slight optimizations):
and one that is shorter (and a probably faster):
The specific casts in your original version an in my 1st version are not really necessary since the Object[] varant does exactly the same thing. I tested both of these and they work as expected.