问:
Parse Error in Matlab: Unexpected Matlab Operator
I'm getting this unwanted parse error saying

Error: File: GUI.m Line: 284 Column: 5. Unexpected MATLAB operator.

However, I cannot see any unexpected operator. Can anybody diagnose this issue?

Here's my code:

```<code>function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
%      GUI, by itself, creates a new GUI or raises the existing
%      singleton*.
%
%      H = GUI returns the handle to a new GUI or the handle to
%      the existing singleton*.
%
%      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI.M with the given input arguments.
%
%      GUI('Property','Value',...) creates a new GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUI

% Last Modified by GUIDE v2.5 24-May-2017 23:28:18

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
end
% End initialization code - DO NOT EDIT

% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GUI (see VARARGIN)

% Choose default command line output for GUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = GUI_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in START.
function START_Callback(hObject, eventdata, handles)
% hObject    handle to START (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global Cfilename;
global Cpathname;
global Tfilename;
global Tpathname;

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

tline = fgetl(fid);
C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});
Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tfilename = C{1,2};

Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

X = strsplit(C{1,1},{'-','.'});

global I;
global J;

I = X{1};
J = X{2};

function fname_Callback(hObject, eventdata, handles)
% hObject    handle to fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of fname as text
%        str2double(get(hObject,'String')) returns contents of fname as a double

% --- Executes during object creation, after setting all properties.
function fname_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function shaColor_Callback(hObject, eventdata, handles)
% hObject    handle to shaColor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of shaColor as text
%        str2double(get(hObject,'String')) returns contents of shaColor as a double

% --- Executes during object creation, after setting all properties.
function shaColor_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shaColor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function char_Callback(hObject, eventdata, handles)
% hObject    handle to char (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of char as text
%        str2double(get(hObject,'String')) returns contents of char as a double

% --- Executes during object creation, after setting all properties.
function char_CreateFcn(hObject, eventdata, handles)
% hObject    handle to char (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function charCol_Callback(hObject, eventdata, handles)
% hObject    handle to charCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of charCol as text
%        str2double(get(hObject,'String')) returns contents of charCol as a double

% --- Executes during object creation, after setting all properties.
function charCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to charCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function GLat_Callback(hObject, eventdata, handles)
% hObject    handle to GLat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of  GLat as text
%        str2double(get(hObject,'String')) returns contents of GLat as a double

% --- Executes during object creation, after setting all properties.
function GLat_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GLat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function GLong_Callback(hObject, eventdata, handles)
% hObject    handle to GLong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GLong as text
%        str2double(get(hObject,'String')) returns contents of GLong as a double

% --- Executes during object creation, after setting all properties.
function GLong_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GLong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
end
set(hObject,'BackgroundColor','white');

function shape_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shape (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function Orient_Callback(hObject, eventdata, handles)
% hObject    handle to Orient (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Orient as text
%        str2double(get(hObject,'String')) returns contents of Orient as a double

function Orient_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Orient (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
     set(hObject,'BackgroundColor','white');
 end

% --- Executes during object creation, after setting all properties.

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in CANCEL.
function CANCEL_Callback(hObject, eventdata, handles)
% hObject    handle to CANCEL (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function gLat2_Callback(hObject, eventdata, handles)
% hObject    handle to gLat2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of gLat2 as text
%        str2double(get(hObject,'String')) returns contents of gLat2 as a double

% --- Executes during object creation, after setting all properties.
function gLat2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gLat2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function gAlt_Callback(hObject, eventdata, handles)
% hObject    handle to gAlt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of gAlt as text
%        str2double(get(hObject,'String')) returns contents of gAlt as a double

% --- Executes during object creation, after setting all properties.
function gAlt_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gAlt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double

% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function GBear_Callback(hObject, eventdata, handles)
% hObject    handle to GBear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GBear as text
%        str2double(get(hObject,'String')) returns contents of GBear as a double

% --- Executes during object creation, after setting all properties.
function GBear_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GBear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in NEXT.
function NEXT_Callback(hObject, eventdata, handles)
% hObject    handle to NEXT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function shape_Callback(hObject, eventdata, handles)
% hObject    handle to shape (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of shape as text
%        str2double(get(hObject,'String')) returns contents of shape as a double

%fid = fopen('C:\Users\Vikcy\Desktop\Files\Values.txt');
%C = textscan(fid, '%s')

% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

% --- Executes on button press in preTar.
function preTar_Callback(hObject, eventdata, handles)
% hObject    handle to preTar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;

J=int32(str2num(J));
J=J-1;
J=int2str(J);

Tfilename = strcat(I,'-',J,'.jpg');

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

for i = 1:count
    tline = fgetl(fid);
end

C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});

Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

axes(handles.axes1);
imshow(image)

% --- Executes on button press in nexTar.
function nexTar_Callback(hObject, eventdata, handles)
% hObject    handle to nexTar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;

J=int32(str2num(J));
J=J+1
J=int2str(J);

Tfilename = strcat(I,'-',J,'.jpg');

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

for i = 1:count
    tline = fgetl(fid);
end

C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});

Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

axes(handles.axes1);
imshow(image)
</code>```

答:
You have an extra end on line 45, just delete it. See below

```<code>    gui_mainfcn(gui_State, varargin{:});
end
end % <- this one
</code>```

Body:
I'm getting this unwanted parse error saying

Error: File: GUI.m Line: 284 Column: 5. Unexpected MATLAB operator.

However, I cannot see any unexpected operator. Can anybody diagnose this issue?

Here's my code:

function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
%      GUI, by itself, creates a new GUI or raises the existing
%      singleton*.
%
%      H = GUI returns the handle to a new GUI or the handle to
%      the existing singleton*.
%
%      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI.M with the given input arguments.
%
%      GUI('Property','Value',...) creates a new GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help GUI

% Last Modified by GUIDE v2.5 24-May-2017 23:28:18

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @GUI_OpeningFcn, ...
                   'gui_OutputFcn',  @GUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
end
% End initialization code - DO NOT EDIT

% --- Executes just before GUI is made visible.
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to GUI (see VARARGIN)

% Choose default command line output for GUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = GUI_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on button press in START.
function START_Callback(hObject, eventdata, handles)
% hObject    handle to START (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global Cfilename;
global Cpathname;
global Tfilename;
global Tpathname;

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

tline = fgetl(fid);
C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});
Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tfilename = C{1,2};

Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

X = strsplit(C{1,1},{'-','.'});

global I;
global J;

I = X{1};
J = X{2};

function fname_Callback(hObject, eventdata, handles)
% hObject    handle to fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of fname as text
%        str2double(get(hObject,'String')) returns contents of fname as a double

% --- Executes during object creation, after setting all properties.
function fname_CreateFcn(hObject, eventdata, handles)
% hObject    handle to fname (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function shaColor_Callback(hObject, eventdata, handles)
% hObject    handle to shaColor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of shaColor as text
%        str2double(get(hObject,'String')) returns contents of shaColor as a double

% --- Executes during object creation, after setting all properties.
function shaColor_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shaColor (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function char_Callback(hObject, eventdata, handles)
% hObject    handle to char (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of char as text
%        str2double(get(hObject,'String')) returns contents of char as a double

% --- Executes during object creation, after setting all properties.
function char_CreateFcn(hObject, eventdata, handles)
% hObject    handle to char (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function charCol_Callback(hObject, eventdata, handles)
% hObject    handle to charCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of charCol as text
%        str2double(get(hObject,'String')) returns contents of charCol as a double

% --- Executes during object creation, after setting all properties.
function charCol_CreateFcn(hObject, eventdata, handles)
% hObject    handle to charCol (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function GLat_Callback(hObject, eventdata, handles)
% hObject    handle to GLat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of  GLat as text
%        str2double(get(hObject,'String')) returns contents of GLat as a double

% --- Executes during object creation, after setting all properties.
function GLat_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GLat (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function GLong_Callback(hObject, eventdata, handles)
% hObject    handle to GLong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GLong as text
%        str2double(get(hObject,'String')) returns contents of GLong as a double

% --- Executes during object creation, after setting all properties.
function GLong_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GLong (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
end
set(hObject,'BackgroundColor','white');

function shape_CreateFcn(hObject, eventdata, handles)
% hObject    handle to shape (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function Orient_Callback(hObject, eventdata, handles)
% hObject    handle to Orient (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of Orient as text
%        str2double(get(hObject,'String')) returns contents of Orient as a double

function Orient_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Orient (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
     set(hObject,'BackgroundColor','white');
 end

% --- Executes during object creation, after setting all properties.

% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in CANCEL.
function CANCEL_Callback(hObject, eventdata, handles)
% hObject    handle to CANCEL (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function gLat2_Callback(hObject, eventdata, handles)
% hObject    handle to gLat2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of gLat2 as text
%        str2double(get(hObject,'String')) returns contents of gLat2 as a double

% --- Executes during object creation, after setting all properties.
function gLat2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gLat2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function gAlt_Callback(hObject, eventdata, handles)
% hObject    handle to gAlt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of gAlt as text
%        str2double(get(hObject,'String')) returns contents of gAlt as a double

% --- Executes during object creation, after setting all properties.
function gAlt_CreateFcn(hObject, eventdata, handles)
% hObject    handle to gAlt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double

% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function GBear_Callback(hObject, eventdata, handles)
% hObject    handle to GBear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of GBear as text
%        str2double(get(hObject,'String')) returns contents of GBear as a double

% --- Executes during object creation, after setting all properties.
function GBear_CreateFcn(hObject, eventdata, handles)
% hObject    handle to GBear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in NEXT.
function NEXT_Callback(hObject, eventdata, handles)
% hObject    handle to NEXT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

function shape_Callback(hObject, eventdata, handles)
% hObject    handle to shape (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of shape as text
%        str2double(get(hObject,'String')) returns contents of shape as a double

%fid = fopen('C:\Users\Vikcy\Desktop\Files\Values.txt');
%C = textscan(fid, '%s')

% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider

% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to slider1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

% --- Executes on button press in preTar.
function preTar_Callback(hObject, eventdata, handles)
% hObject    handle to preTar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;

J=int32(str2num(J));
J=J-1;
J=int2str(J);

Tfilename = strcat(I,'-',J,'.jpg');

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

for i = 1:count
    tline = fgetl(fid);
end

C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});

Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

axes(handles.axes1);
imshow(image)

% --- Executes on button press in nexTar.
function nexTar_Callback(hObject, eventdata, handles)
% hObject    handle to nexTar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global Tfilename;
global Tpathname;
global I;
global J;

J=int32(str2num(J));
J=J+1
J=int2str(J);

Tfilename = strcat(I,'-',J,'.jpg');

fid = fopen('C:\Users\Vikcy\Desktop\Flight Images\Values.txt');

for i = 1:count
    tline = fgetl(fid);
end

C = strsplit(tline,{',',' ','[',']'});

set(handles.fname,'String',C{1,2});
set(handles.shape,'String',C{1,3});
set(handles.shaColor,'String',C{1,4});
set(handles.char,'String',C{1,5});
set(handles.charCol,'String',C{1,6});
set(handles.GLat,'String',C{1,7});
set(handles.GLong,'String',C{1,8});
set(handles.Orient,'String',C{1,9});

Cpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Cfilename = 'I.jpg'

Cvar=strcat(Cpathname,Cfilename);
CORI_IMG=imread(Cvar);
%axis(handles.axes1);
%imshow(CORI_IMG);
imshow(CORI_IMG,'Parent',handles.axes1)

Tpathname = 'C:\Users\Vikcy\Desktop\Flight Images\';
Tvar=strcat(Tpathname,Tfilename);
TORI_IMG=imread(Tvar);
%axis(handles.axes2);
%imshow(TORI_IMG);
imshow(TORI_IMG,'Parent',handles.axes2)

axes(handles.axes1);
imshow(image)

Body:
You have an extra end on line 45, just delete it. See below

    gui_mainfcn(gui_State, varargin{:});
end
end % <- this one


来源: stackexchange

问:
Bidirectional UDP Port for docker container
I have a consul running in a docker container.

When I start another consul agent (not on docker), it says:

```<code>[WARN] memberlist: Was able to reach container_name via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
</code>```

I am trying to form a cluster here, but leader election keeps failing.

How can I fix this?

My port specification in docker-compose.yml (docker-compose version: 1)

```<code>  ports:
    - "8300:8300"
    - "8301:8301"
    - "8301:8301/udp"
    - "8302:8302"
    - "8302:8302/udp"
    - "8400:8400"
    - "8500:8500"
    - "8600:8600"
    - "8600:8600/udp"
</code>```

Log of Consul1 running in Docker Container:

```<code>         Node name: '<host>'
        Datacenter: 'dc1'
            Server: true (bootstrap: true)
       Client Addr: 0.0.0.0 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)
      Cluster Addr: <host_ip> (LAN: 8301, WAN: 8302)
    Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
             Atlas: <disabled>

==> Log data will now stream in as it occurs:

    2017/06/08 03:39:44 [INFO] raft: Restored from snapshot 13-35418-1496826625488
    2017/06/08 03:39:44 [INFO] serf: EventMemberJoin: <host> <host_ip>
    2017/06/08 03:39:44 [INFO] raft: Node at <host_ip>:8300 [Follower] entering Follower state
    2017/06/08 03:39:44 [INFO] consul: adding LAN server <host> (Addr: <host_ip>:8300) (DC: dc1)
    2017/06/08 03:39:44 [INFO] serf: EventMemberJoin: <host>.dc1 <host_ip>
    2017/06/08 03:39:44 [INFO] consul: adding WAN server <host>.dc1 (Addr: <host_ip>:8300) (DC: dc1)
    2017/06/08 03:39:44 [ERR] agent: failed to sync remote state: No cluster leader
    2017/06/08 03:39:45 [WARN] raft: Heartbeat timeout reached, starting election
    2017/06/08 03:39:45 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:39:45 [INFO] raft: Election won. Tally: 1
    2017/06/08 03:39:45 [INFO] raft: Node at <host_ip>:8300 [Leader] entering Leader state
    2017/06/08 03:39:45 [INFO] consul: cluster leadership acquired
    2017/06/08 03:39:45 [INFO] consul: New leader elected: <host>
    2017/06/08 03:39:45 [INFO] raft: Disabling EnableSingleNode (bootstrap)
    2017/06/08 03:39:45 [INFO] raft: Added peer <host_ip>:9300, starting replication
    2017/06/08 03:39:45 [INFO] raft: Removed peer <host_ip>:9300, stopping replication (Index: 36201)
    2017/06/08 03:39:45 [INFO] raft: Added peer <host_ip>:9300, starting replication
    2017/06/08 03:39:45 [INFO] raft: Added peer <host_ip>:10300, starting replication
    2017/06/08 03:39:45 [INFO] raft: Removed peer <host_ip>:10300, stopping replication (Index: 36228)
    2017/06/08 03:39:45 [INFO] raft: Removed peer <host_ip>:9300, stopping replication (Index: 36230)
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:10300: dial tcp <host_ip>:10300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:10300: dial tcp <host_ip>:10300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:39:49 [WARN] agent: Check 'vault::8200:vault-sealed-check' missed TTL, is now critical
    2017/06/08 03:39:50 [INFO] serf: EventMemberJoin: server2 <host_ip>
    2017/06/08 03:39:50 [INFO] consul: adding LAN server server2 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 03:39:50 [INFO] raft: Added peer <host_ip>:9300, starting replication
    2017/06/08 03:39:50 [WARN] raft: AppendEntries to <host_ip>:9300 rejected, sending older logs (next: 36231)
    2017/06/08 03:39:50 [INFO] raft: pipelining replication to peer <host_ip>:9300
    2017/06/08 03:39:50 [INFO] consul: member 'server2' joined, marking health alive
    2017/06/08 03:39:52 [INFO] agent: Synced service 'vault::8200'
    2017/06/08 03:39:52 [INFO] agent: Synced check 'vault::8200:vault-sealed-check'
    2017/06/08 03:40:06 [INFO] agent: Synced check 'vault::8200:vault-sealed-check'
    2017/06/08 03:40:18 [ERR] raft: Failed to heartbeat to <host_ip>:9300: EOF
    2017/06/08 03:40:18 [INFO] raft: aborting pipeline replication to peer <host_ip>:9300
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to heartbeat to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to heartbeat to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to heartbeat to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [WARN] raft: Failed to contact <host_ip>:9300 in 501.593114ms
    2017/06/08 03:40:19 [WARN] raft: Failed to contact quorum of nodes, stepping down
    2017/06/08 03:40:19 [INFO] raft: Node at <host_ip>:8300 [Follower] entering Follower state
    2017/06/08 03:40:19 [INFO] consul: cluster leadership lost
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:20 [WARN] raft: Heartbeat timeout reached, starting election
    2017/06/08 03:40:20 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:20 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:21 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:22 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:22 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:22 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:23 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:23 [WARN] dns: Query results too stale, re-requesting
    2017/06/08 03:40:23 [ERR] dns: rpc error: No cluster leader
    2017/06/08 03:40:23 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:23 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:23 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:24 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:24 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:24 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:24 [ERR] http: Request PUT /v1/session/renew/8c4efe65-07c3-f93e-6679-f2bc95f8e92c, error: No cluster leader from=172.17.0.4:57031
    2017/06/08 03:40:25 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:25 [ERR] http: Request PUT /v1/session/renew/8c4efe65-07c3-f93e-6679-f2bc95f8e92c, error: No cluster leader from=172.17.0.4:57061
    2017/06/08 03:40:26 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:26 [INFO] memberlist: Marking server2 as failed, suspect timeout reached
    2017/06/08 03:40:26 [INFO] serf: EventMemberFailed: server2 <host_ip>
    2017/06/08 03:40:26 [INFO] consul: removing LAN server server2 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 03:40:26 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:26 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:26 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:26 [ERR] agent: coordinate update error: No cluster leader
    2017/06/08 03:40:26 [ERR] http: Request PUT /v1/session/renew/8c4efe65-07c3-f93e-6679-f2bc95f8e92c, error: No cluster leader from=172.17.0.4:57064
    2017/06/08 03:40:27 [WARN] dns: Query results too stale, re-requesting
    2017/06/08 03:40:27 [ERR] dns: rpc error: No cluster leader
    2017/06/08 03:40:27 [WARN] raft: Election timeout reached, restarting election
</code>```

Log of consul2:

```<code>==> WARNING: Expect Mode enabled, expecting 2 servers
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
         Node name: 'server2'
        Datacenter: 'dc1'
            Server: true (bootstrap: false)
       Client Addr: 0.0.0.0 (HTTP: 9500, HTTPS: -1, DNS: 9600, RPC: 9400)
      Cluster Addr: <host_ip> (LAN: 9301, WAN: 9302)
    Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
             Atlas: <disabled>

==> Log data will now stream in as it occurs:

    2017/06/08 09:09:50 [INFO] raft: Restored from snapshot 13-35418-1496892834061
    2017/06/08 09:09:50 [INFO] serf: EventMemberJoin: server2 <host_ip>
    2017/06/08 09:09:50 [INFO] serf: EventMemberJoin: server2.dc1 <host_ip>
    2017/06/08 09:09:50 [INFO] raft: Node at <host_ip>:9300 [Follower] entering Follower state
    2017/06/08 09:09:50 [INFO] consul: adding LAN server server2 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 09:09:50 [INFO] consul: adding WAN server server2.dc1 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 09:09:50 [ERR] agent: failed to sync remote state: No cluster leader
    2017/06/08 09:09:50 [INFO] agent: Joining cluster...
    2017/06/08 09:09:50 [INFO] agent: (LAN) joining: [<host_ip>:8301 <host_ip>:10301]
    2017/06/08 09:09:50 [INFO] serf: EventMemberJoin: <host> <host_ip>
    2017/06/08 09:09:50 [INFO] consul: adding LAN server <host> (Addr: <host_ip>:8300) (DC: dc1)
    2017/06/08 09:09:50 [INFO] agent: (LAN) joined: 1 Err: <nil>
    2017/06/08 09:09:50 [INFO] agent: Join completed. Synced with 1 initial agents
    2017/06/08 09:09:50 [WARN] raft: Failed to get previous log: 36233 log not found (last: 36230)
    2017/06/08 09:09:50 [INFO] raft: Removed ourself, transitioning to follower
    2017/06/08 09:09:50 [INFO] raft: Removed ourself, transitioning to follower
    2017/06/08 09:09:52 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
==> Newer Consul version available: 0.8.3
    2017/06/08 09:09:54 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
    2017/06/08 09:09:56 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
    2017/06/08 09:09:57 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
</code>```

答:
What consul means regarding bidirectional UDP is that consul agent needs to see it's consul server and vice versa, consul server needs to see it's agent.

```<code>Consul agent -- [UDP] --> Consul Server
Consul agent <--[UDP] --  Consul Server
</code>```

They are two different communications, unlike TCP, which uses the same channel that the Agent already initiated.

So, if your consul's agent and server are not in the same network (i.e. docker network) you need to expose ports in both ends. And take in account the concept of advertise that is the address that the agent announces to be contacted to.

ContentLicense: CC BY-SA 3.0

Body:
I have a consul running in a docker container.

When I start another consul agent (not on docker), it says:

[WARN] memberlist: Was able to reach container_name via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP

I am trying to form a cluster here, but leader election keeps failing.

How can I fix this?

My port specification in docker-compose.yml (docker-compose version: 1)

  ports:
    - "8300:8300"
    - "8301:8301"
    - "8301:8301/udp"
    - "8302:8302"
    - "8302:8302/udp"
    - "8400:8400"
    - "8500:8500"
    - "8600:8600"
    - "8600:8600/udp"

Log of Consul1 running in Docker Container:

         Node name: '<host>'
        Datacenter: 'dc1'
            Server: true (bootstrap: true)
       Client Addr: 0.0.0.0 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400)
      Cluster Addr: <host_ip> (LAN: 8301, WAN: 8302)
    Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
             Atlas: <disabled>

==> Log data will now stream in as it occurs:

    2017/06/08 03:39:44 [INFO] raft: Restored from snapshot 13-35418-1496826625488
    2017/06/08 03:39:44 [INFO] serf: EventMemberJoin: <host> <host_ip>
    2017/06/08 03:39:44 [INFO] raft: Node at <host_ip>:8300 [Follower] entering Follower state
    2017/06/08 03:39:44 [INFO] consul: adding LAN server <host> (Addr: <host_ip>:8300) (DC: dc1)
    2017/06/08 03:39:44 [INFO] serf: EventMemberJoin: <host>.dc1 <host_ip>
    2017/06/08 03:39:44 [INFO] consul: adding WAN server <host>.dc1 (Addr: <host_ip>:8300) (DC: dc1)
    2017/06/08 03:39:44 [ERR] agent: failed to sync remote state: No cluster leader
    2017/06/08 03:39:45 [WARN] raft: Heartbeat timeout reached, starting election
    2017/06/08 03:39:45 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:39:45 [INFO] raft: Election won. Tally: 1
    2017/06/08 03:39:45 [INFO] raft: Node at <host_ip>:8300 [Leader] entering Leader state
    2017/06/08 03:39:45 [INFO] consul: cluster leadership acquired
    2017/06/08 03:39:45 [INFO] consul: New leader elected: <host>
    2017/06/08 03:39:45 [INFO] raft: Disabling EnableSingleNode (bootstrap)
    2017/06/08 03:39:45 [INFO] raft: Added peer <host_ip>:9300, starting replication
    2017/06/08 03:39:45 [INFO] raft: Removed peer <host_ip>:9300, stopping replication (Index: 36201)
    2017/06/08 03:39:45 [INFO] raft: Added peer <host_ip>:9300, starting replication
    2017/06/08 03:39:45 [INFO] raft: Added peer <host_ip>:10300, starting replication
    2017/06/08 03:39:45 [INFO] raft: Removed peer <host_ip>:10300, stopping replication (Index: 36228)
    2017/06/08 03:39:45 [INFO] raft: Removed peer <host_ip>:9300, stopping replication (Index: 36230)
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:10300: dial tcp <host_ip>:10300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:10300: dial tcp <host_ip>:10300: getsockopt: connection refused
    2017/06/08 03:39:45 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:39:49 [WARN] agent: Check 'vault::8200:vault-sealed-check' missed TTL, is now critical
    2017/06/08 03:39:50 [INFO] serf: EventMemberJoin: server2 <host_ip>
    2017/06/08 03:39:50 [INFO] consul: adding LAN server server2 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 03:39:50 [INFO] raft: Added peer <host_ip>:9300, starting replication
    2017/06/08 03:39:50 [WARN] raft: AppendEntries to <host_ip>:9300 rejected, sending older logs (next: 36231)
    2017/06/08 03:39:50 [INFO] raft: pipelining replication to peer <host_ip>:9300
    2017/06/08 03:39:50 [INFO] consul: member 'server2' joined, marking health alive
    2017/06/08 03:39:52 [INFO] agent: Synced service 'vault::8200'
    2017/06/08 03:39:52 [INFO] agent: Synced check 'vault::8200:vault-sealed-check'
    2017/06/08 03:40:06 [INFO] agent: Synced check 'vault::8200:vault-sealed-check'
    2017/06/08 03:40:18 [ERR] raft: Failed to heartbeat to <host_ip>:9300: EOF
    2017/06/08 03:40:18 [INFO] raft: aborting pipeline replication to peer <host_ip>:9300
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to heartbeat to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to heartbeat to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [ERR] raft: Failed to heartbeat to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:19 [WARN] raft: Failed to contact <host_ip>:9300 in 501.593114ms
    2017/06/08 03:40:19 [WARN] raft: Failed to contact quorum of nodes, stepping down
    2017/06/08 03:40:19 [INFO] raft: Node at <host_ip>:8300 [Follower] entering Follower state
    2017/06/08 03:40:19 [INFO] consul: cluster leadership lost
    2017/06/08 03:40:19 [ERR] raft: Failed to AppendEntries to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:20 [WARN] raft: Heartbeat timeout reached, starting election
    2017/06/08 03:40:20 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:20 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:21 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:22 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:22 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:22 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:23 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:23 [WARN] dns: Query results too stale, re-requesting
    2017/06/08 03:40:23 [ERR] dns: rpc error: No cluster leader
    2017/06/08 03:40:23 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:23 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:23 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:24 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:24 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:24 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:24 [ERR] http: Request PUT /v1/session/renew/8c4efe65-07c3-f93e-6679-f2bc95f8e92c, error: No cluster leader from=172.17.0.4:57031
    2017/06/08 03:40:25 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:25 [ERR] http: Request PUT /v1/session/renew/8c4efe65-07c3-f93e-6679-f2bc95f8e92c, error: No cluster leader from=172.17.0.4:57061
    2017/06/08 03:40:26 [INFO] memberlist: Suspect server2 has failed, no acks received
    2017/06/08 03:40:26 [INFO] memberlist: Marking server2 as failed, suspect timeout reached
    2017/06/08 03:40:26 [INFO] serf: EventMemberFailed: server2 <host_ip>
    2017/06/08 03:40:26 [INFO] consul: removing LAN server server2 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 03:40:26 [WARN] raft: Election timeout reached, restarting election
    2017/06/08 03:40:26 [INFO] raft: Node at <host_ip>:8300 [Candidate] entering Candidate state
    2017/06/08 03:40:26 [ERR] raft: Failed to make RequestVote RPC to <host_ip>:9300: dial tcp <host_ip>:9300: getsockopt: connection refused
    2017/06/08 03:40:26 [ERR] agent: coordinate update error: No cluster leader
    2017/06/08 03:40:26 [ERR] http: Request PUT /v1/session/renew/8c4efe65-07c3-f93e-6679-f2bc95f8e92c, error: No cluster leader from=172.17.0.4:57064
    2017/06/08 03:40:27 [WARN] dns: Query results too stale, re-requesting
    2017/06/08 03:40:27 [ERR] dns: rpc error: No cluster leader
    2017/06/08 03:40:27 [WARN] raft: Election timeout reached, restarting election

Log of consul2:

==> WARNING: Expect Mode enabled, expecting 2 servers
==> Starting Consul agent...
==> Starting Consul agent RPC...
==> Consul agent running!
         Node name: 'server2'
        Datacenter: 'dc1'
            Server: true (bootstrap: false)
       Client Addr: 0.0.0.0 (HTTP: 9500, HTTPS: -1, DNS: 9600, RPC: 9400)
      Cluster Addr: <host_ip> (LAN: 9301, WAN: 9302)
    Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
             Atlas: <disabled>

==> Log data will now stream in as it occurs:

    2017/06/08 09:09:50 [INFO] raft: Restored from snapshot 13-35418-1496892834061
    2017/06/08 09:09:50 [INFO] serf: EventMemberJoin: server2 <host_ip>
    2017/06/08 09:09:50 [INFO] serf: EventMemberJoin: server2.dc1 <host_ip>
    2017/06/08 09:09:50 [INFO] raft: Node at <host_ip>:9300 [Follower] entering Follower state
    2017/06/08 09:09:50 [INFO] consul: adding LAN server server2 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 09:09:50 [INFO] consul: adding WAN server server2.dc1 (Addr: <host_ip>:9300) (DC: dc1)
    2017/06/08 09:09:50 [ERR] agent: failed to sync remote state: No cluster leader
    2017/06/08 09:09:50 [INFO] agent: Joining cluster...
    2017/06/08 09:09:50 [INFO] agent: (LAN) joining: [<host_ip>:8301 <host_ip>:10301]
    2017/06/08 09:09:50 [INFO] serf: EventMemberJoin: <host> <host_ip>
    2017/06/08 09:09:50 [INFO] consul: adding LAN server <host> (Addr: <host_ip>:8300) (DC: dc1)
    2017/06/08 09:09:50 [INFO] agent: (LAN) joined: 1 Err: <nil>
    2017/06/08 09:09:50 [INFO] agent: Join completed. Synced with 1 initial agents
    2017/06/08 09:09:50 [WARN] raft: Failed to get previous log: 36233 log not found (last: 36230)
    2017/06/08 09:09:50 [INFO] raft: Removed ourself, transitioning to follower
    2017/06/08 09:09:50 [INFO] raft: Removed ourself, transitioning to follower
    2017/06/08 09:09:52 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
==> Newer Consul version available: 0.8.3
    2017/06/08 09:09:54 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
    2017/06/08 09:09:56 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP
    2017/06/08 09:09:57 [WARN] memberlist: Was able to reach <host> via TCP but not UDP, network may be misconfigured and not allowing bidirectional UDP

Body:
What consul means regarding bidirectional UDP is that consul agent needs to see it's consul server and vice versa, consul server needs to see it's agent.

Consul agent -- [UDP] --> Consul Server
Consul agent <--[UDP] --  Consul Server

They are two different communications, unlike TCP, which uses the same channel that the Agent already initiated.

So, if your consul's agent and server are not in the same network (i.e. docker network) you need to expose ports in both ends. And take in account the concept of advertise that is the address that the agent announces to be contacted to.


问:
Left position property of the handle in noUiSlider
I am trying to get the current left property value of the div handle of noUiSlider as I slide. But I am getting always its initial left property value.

$(document).ready(function() {
  var slider = document.getElementById('slider');

  noUiSlider.create(slider, {
    start: [1],
    connect: true,
    range: {
      'min': 0,
      'max': 10
    }
  });

  slider.noUiSlider.on('slide', function() {
    var handle = $("div.noUi-handle");
    $(leftPosition).text(($(handle).position().left));
  });
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/10.0.0/nouislider.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/10.0.0/nouislider.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="slider">
</div>
<div id="leftPosition"></div></code>```

答:
The slide event gets 5 arguments: values, handle, unencoded, tap, positions.

The 5th positions argument contains the left positions, in percentages.

Body:
I am trying to get the current left property value of the div handle of noUiSlider as I slide. But I am getting always its initial left property value.

$(document).ready(function() {
  var slider = document.getElementById('slider');

  noUiSlider.create(slider, {
    start: [1],
    connect: true,
    range: {
      'min': 0,
      'max': 10
    }
  });

  slider.noUiSlider.on('slide', function() {
    var handle = $("div.noUi-handle");
    $(leftPosition).text(($(handle).position().left));
  });
});

<link href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/10.0.0/nouislider.css" rel="stylesheet"/>


问:
How to install titan 1.0.0 api for java
I'm able to run groovy scripts via the gremlin console, but I wish to use titan db in Java files and I can't find a way to install Titan API for java.</p>

答:
There is an example of a maven project using Titan here:

https://github.com/pluradj/titan-tp3-java-example

Title: How to install titan 1.0.0 api for java


问:
XSLT for-each failing to pick up fields
I've got a curious item, I'm trying to enumerate through an xml file with my XSLT transform, however I'm after putting a for-each loop into the code my records are not pulling any details (anymore).  Help!

XSLT

```<code>    <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
    <xsl:variable name="pathid" select="montage/path" />
    <xsl:variable name="outputstr" select="''" />
    <xsl:template match="vista">
        <xsl:variable name="pathid" select="path" />
        <html>
            <body>
                <div align="center">
                    <table border="0" cellpadding="0" cellspacing="0" width="800" height="200">
                        <xsl:apply-templates select="item" />
                    </table>
                </div>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="item">
        <xsl:variable name="monid" select="mon" />
            <!--<xsl:value-of select="format-number(position(), '#')" />-->
        <xsl:variable name="outputstr" select="file" />
            <xsl:choose>
                <xsl:when test="position() >= 0 and 4 > position()">
                    <tr height="200">
                    <xsl:for-each select="item">
                        <td width="157" height="108" valign="top">
                            <xsl:attribute name="height">
                                <xsl:value-of select="'200'"/>
                            </xsl:attribute>
                            <a>
                                <xsl:attribute name="href">
                                    <xsl:value-of select="$pathid" />
                                    <xsl:value-of select="thepage" />
                                </xsl:attribute>
                                <img>
                                    <xsl:attribute name="src">
                                        <xsl:value-of select="concat(substring-before($outputstr,'abc'),$pathid)"/>
                                        <xsl:value-of select="$outputstr" />
                                    </xsl:attribute>
                                </img>
                            </a>
                        </td>
                        </xsl:for-each>
                    </tr>
                </xsl:when>
            </xsl:choose>
            <xsl:attribute name="id">mon</xsl:attribute>
    </xsl:template>
</xsl:stylesheet>
</code>```

XML

```<code><?xml version="1.0"?>
<vista>
    <lastupdate>14/12/2010 14:32</lastupdate>
    <path>C:\</path>
    <item>
        <thepage>00000657.html</thepage>
        <heading>heading1</heading>
        <file>test123.png</file>
        <description>df bhdf hdfhdf hdfh he rher herh df bdf bdfb df rfbd bd</description>
    </item>
    <item>
        <thepage>00000660.html</thepage>
        <heading>heading2</heading>
        <file>test456.jpg</file>
        <description>reh erh erherh erh erher herh</description>
    </item>
</vista>
</code>```

Outputted HTML

```<code><html>
<body>
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="800" height="200">
<tr height="200"></tr>
<tr height="200"></tr>
<tr height="200"></tr>
<tr height="100"></tr>
<tr height="100"></tr>
<tr height="100"></tr>
<tr height="100"></tr>
</table>
</div>
</body>
</html>
</code>```

答: The line <xsl:for-each select="item"> - I think you're already in "item".  You can't select it again.

ContentLicense: CC BY-SA 2.5

Title: XSLT for-each failing to pick up fields

Body:
I've got a curious item, I'm trying to enumerate through an xml file with my XSLT transform, however I'm after putting a for-each loop into the code my records are not pulling any details (anymore).  Help!

XSLT

    <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>
    <xsl:variable name="pathid" select="montage/path" />
    <xsl:variable name="outputstr" select="''" />
    <xsl:template match="vista">
        <xsl:variable name="pathid" select="path" />

                        <xsl:apply-templates select="item" />

    </xsl:template>
    <xsl:template match="item">
        <xsl:variable name="monid" select="mon" />

        <xsl:variable name="outputstr" select="file" />
            <xsl:choose>
                <xsl:when test="position() >= 0 and 4 > position()">

                    <xsl:for-each select="item">

                            <xsl:attribute name="height">
                                <xsl:value-of select="'200'"/>
                            </xsl:attribute>

                                <xsl:attribute name="href">
                                    <xsl:value-of select="$pathid" />
                                    <xsl:value-of select="thepage" />
                                </xsl:attribute>

                                    <xsl:attribute name="src">
                                        <xsl:value-of select="concat(substring-before($outputstr,'abc'),$pathid)"/>
                                        <xsl:value-of select="$outputstr" />
                                    </xsl:attribute>

                        </xsl:for-each>

                </xsl:when>
            </xsl:choose>
            <xsl:attribute name="id">mon</xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

XML

<?xml version="1.0"?>
<vista>
    <lastupdate>14/12/2010 14:32</lastupdate>
    <path>C:\</path>
    <item>
        <thepage>00000657.html</thepage>
        <heading>heading1</heading>
        <file>test123.png</file>
        <description>df bhdf hdfhdf hdfh he rher herh df bdf bdfb df rfbd bd</description>
    </item>
    <item>
        <thepage>00000660.html</thepage>
        <heading>heading2</heading>
        <file>test456.jpg</file>
        <description>reh erh erherh erh erher herh</description>
    </item>
</vista>

Outputted HTML


答:
From the Matlab documentation:

Functions end with either an end statement, the end of the file, or the definition line for a local function, whichever comes first. The end statement is required if:

Any function in the file contains a nested function (a function completely contained within its parent).

The function is a local function within a function file, and any local function in the file uses the end keyword.

The function is a local function within a script file.

You use the end keyword in your function Orient_CreateFcn, so all of your local functions require an end statement.

This is good coding practise anyway, as it makes your code more clear. For example it clarifies whether a local function is nested or not without having to find the parent function's end

Title: Parse Error in Matlab: Unexpected Matlab Operator


问:
keyset and key different data type
I am seeing a unique situation where my keyset and key of a LinkedHashSet are containing different data types as shown below

As you can see that the key is a String and the keyset is a long.

Following code is failing because of that:

```<code>modifiedRowKeys.toArray(new Long[modifiedRowKeys.size()]);
</code>```

I get ArrayStoreException for String values.

I was able to replicate this from Angular application where i am sending a Map<Long, Map<String,Object>> to my Spring server which contains the data as shared in the pic.

Edit 1:

Please see following strange behavior in eclipse:

Could it be an issue with Jackson Mapper which we are using for conversion of objects ?

Edit 2:

The following code fails with ClassCastException saying

String cannot be cast to Long

```<code>Set<Long> modifiedRowKeys = modifiedRowMap.keySet();
Long[] periodDateArray = new Long[modifiedRowKeys.size()];

int count = 0;
Iterator<Long> keyIterator = modifiedRowKeys.iterator();
while(keyIterator.hasNext()){
    Long key = keyIterator.next();
    System.out.println("key instanceof Long : " + (key instanceof Long));
    periodDateArray[count++] = Long.valueOf(key);
}
</code>```

This seems pretty straight forward logic !

Edit 3:

I have recreated the problem as follows:

```<code>    public static void main(String[] args) {

        CollectionsToArray collectionsToArray = new CollectionsToArray();

        Map<String, Map<String, Object>> mapOfNumbers = collectionsToArray.prepareStrangeNumbersSetFromMapOfMap();

        Object obj = mapOfNumbers;
        collectionsToArray.convertMapToKeySetToArray(obj);

    }

    private Map<String, Map<String, Object>> prepareStrangeNumbersSetFromMapOfMap() {
        Map<String, Map<String, Object>> longNumberMap = new LinkedHashMap<>();

        Map<String, Object> stringValueMap = new HashMap<>();
        stringValueMap.put("Adams", "Adithya");
        stringValueMap.put("Edge", 80);

        longNumberMap.put("1488376800000", stringValueMap);

        return longNumberMap;
    }

    private void convertMapToKeySetToArray(Object obj) {
        Map<Long, Map<String, Object>> mapOfNumbers = (Map<Long, Map<String, Object>>) obj;
        Set<Long> stringNumbers = mapOfNumbers.keySet();

        convertLongKeySetToArray(stringNumbers);
    }

    private void convertLongKeySetToArray(Set<Long> stringNumbers) {
        Long[] stringNumbersArray = stringNumbers.toArray(new Long[0]);
        Arrays.sort(stringNumbersArray);

        System.out.println(stringNumbersArray);
    }
</code>```

答:
If I run the code in your "Edit 2" with a Map<Long, String> it compiles and runs fine. So the problem is not in what you've shown so far. As said above, try to create a [mcve] that does reproduce the problem.

My best guess is that you have something like this:

```<code>Map m = new HashMap (); //raw map received from jackson
m.put("abc", "def"); //it's in fact a Map<String, String>
Map<Long, String> modifiedRowMap = m; //but you cast it to something else
</code>```

The rest of the code will compile but you will get an exception at runtime.

Title: keyset and key different data type

Body:
I am seeing a unique situation where my keyset and key of a LinkedHashSet are containing different data types as shown below

As you can see that the key is a String and the keyset is a long.

Following code is failing because of that:

modifiedRowKeys.toArray(new Long[modifiedRowKeys.size()]);

I get ArrayStoreException for String values.

I was able to replicate this from Angular application where i am sending a Map<Long, Map<String,Object>> to my Spring server which contains the data as shared in the pic.

Edit 1:

Please see following strange behavior in eclipse:

Could it be an issue with Jackson Mapper which we are using for conversion of objects ?

Edit 2:

The following code fails with ClassCastException saying

String cannot be cast to Long

Set<Long> modifiedRowKeys = modifiedRowMap.keySet();
Long[] periodDateArray = new Long[modifiedRowKeys.size()];

int count = 0;
Iterator<Long> keyIterator = modifiedRowKeys.iterator();
while(keyIterator.hasNext()){
    Long key = keyIterator.next();
    System.out.println("key instanceof Long : " + (key instanceof Long));
    periodDateArray[count++] = Long.valueOf(key);
}

This seems pretty straight forward logic !

Edit 3:

I have recreated the problem as follows:

    public static void main(String[] args) {

        CollectionsToArray collectionsToArray = new CollectionsToArray();

        Map<String, Map<String, Object>> mapOfNumbers = collectionsToArray.prepareStrangeNumbersSetFromMapOfMap();

        Object obj = mapOfNumbers;
        collectionsToArray.convertMapToKeySetToArray(obj);

    }

    private Map<String, Map<String, Object>> prepareStrangeNumbersSetFromMapOfMap() {
        Map<String, Map<String, Object>> longNumberMap = new LinkedHashMap<>();

        Map<String, Object> stringValueMap = new HashMap<>();
        stringValueMap.put("Adams", "Adithya");
        stringValueMap.put("Edge", 80);

        longNumberMap.put("1488376800000", stringValueMap);

        return longNumberMap;
    }

    private void convertMapToKeySetToArray(Object obj) {
        Map<Long, Map<String, Object>> mapOfNumbers = (Map<Long, Map<String, Object>>) obj;
        Set<Long> stringNumbers = mapOfNumbers.keySet();

        convertLongKeySetToArray(stringNumbers);
    }

    private void convertLongKeySetToArray(Set<Long> stringNumbers) {
        Long[] stringNumbersArray = stringNumbers.toArray(new Long[0]);
        Arrays.sort(stringNumbersArray);

        System.out.println(stringNumbersArray);
    }

Body:
If I run the code in your "Edit 2" with a Map<Long, String> it compiles and runs fine. So the problem is not in what you've shown so far. As said above, try to create a [mcve] that does reproduce the problem.

My best guess is that you have something like this:

Map m = new HashMap (); //raw map received from jackson
m.put("abc", "def"); //it's in fact a Map<String, String>
Map<Long, String> modifiedRowMap = m; //but you cast it to something else

The rest of the code will compile but you will get an exception at runtime.


问:
Cannot install NodeJs: /usr/bin/env: node: No such file or directory
I'm trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs.

I've read about Ubuntu different way of doing it (issues?), so this is what I've done in order to install it:

```<code>sudo apt-get install npm

sudo npm install -g grunt-cli
</code>```

Typing grunt after that I've got the error:

```<code>/usr/bin/env: node: No such file or directory
</code>```

So, I've tried:

```<code>curl -sL https://deb.nodesource.com/setup | sudo bash -

sudo apt-get install -y nodejs

sudo apt-get update
</code>```

And trying again, and still getting the error, I've tried:

```<code>sudo add-apt-repository https://launchpad.net/~chris-lea/+archive/node.js/

sudo apt-get install -y nodejs
</code>```

I've got this message:

```<code>nodejs is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.
</code>```

I did try a cleanup just in case:

```<code>sudo apt-get autoremove
</code>```

But nope, the error is still there: when I type grunt I still get /usr/bin/env: node: No such file or directory

What should I do?

答:
Just do

```<code>$ sudo apt-get install nodejs-legacy
</code>```

And it will start working.

Body:
I'm trying to install nodeJs into my Ubuntu 14.04 in order to use GruntJs.

I've read about Ubuntu different way of doing it (issues?), so this is what I've done in order to install it:

sudo apt-get install npm

sudo npm install -g grunt-cli

Typing grunt after that I've got the error:

/usr/bin/env: node: No such file or directory

So, I've tried:

curl -sL https://deb.nodesource.com/setup | sudo bash -

sudo apt-get install -y nodejs

sudo apt-get update

And trying again, and still getting the error, I've tried:

sudo add-apt-repository https://launchpad.net/~chris-lea/+archive/node.js/

sudo apt-get install -y nodejs

I've got this message:

nodejs is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.

I did try a cleanup just in case:

sudo apt-get autoremove

But nope, the error is still there: when I type grunt I still get /usr/bin/env: node: No such file or directory

What should I do?

Body:
Just do

$ sudo apt-get install nodejs-legacy

And it will start working.


问:
How to add an extra textfield when user clicks on a button?
I have this code

<input type="text" name="search" placeholder="Author...">

I want a button and when I click on it, it should show this textfield and the button should disappear.

答:
Try this</p>

```<code><script>

function next(){

document.getElementById("text").hidden=false;
document.getElementById("addBtn").hidden=true;

}
 </script>

<input type="text" name="search" placeholder="Author..." id="text" hidden="true">
<input type="button" value="Add" onclick="next()" id="addBtn">
</code>```

Body:
Try this

<script>

function next(){

document.getElementById("text").hidden=false;
document.getElementById("addBtn").hidden=true;

}
 </script>

<input type="text" name="search" placeholder="Author..." id="text" hidden="true">
<input type="button" value="Add" onclick="next()" id="addBtn">


问:
Getting error message as Failed to read schema document 'http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd'
I am trying to deploy a Mule app on Mule standalone 3.8.1, but I am getting this error message:

```<code>Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[?:?]
</code>```

It works fine when running from Anypoint Studio using Mule server 3.8.2 EE.

答: DataWeave is an enterprise feature, you can't use it when you deploy to a CE runtime.</p>

ContentLicense: CC BY-SA 4.0

Body:
I am trying to deploy a Mule app on Mule standalone 3.8.1, but I am getting this error message:

Ignored XML validation warning
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[?:?]

It works fine when running from Anypoint Studio using Mule server 3.8.2 EE.


问:
undefined method `two_dimensional?' using Barby CairoOutputter
I just want to generate a QR code using rqrcode gem. When I create my new rqrcode instance:

```<code>qr = RQRCode::QRCode.new('test')
</code>```

I get the following input :

```<code>xxxxxxx  x  x x  xxxxxx x xxxxxxx
x     x xx xxxxx     xx   x     x
x xxx x   x   x xxxx  xx  x xxx x
x xxx x   x x x x  x x xx x xxx x
x xxx x  x   xxx xxx    x x xxx x
x     x xxx  x    xx      x     x
xxxxxxx x x x x x x x x x xxxxxxx
        x x     xx   x x
    xxxx  xxxxx  xxxx   x xx   x
 x  xx xxxx   xxxx xxxx    x  xxx
xx x xx   x x  xxxx            xx
  x  x x  xxx xxxxxxx x xx xxx  x
x  xxxxxxx x x x xxxx xx xx  xx
x x x         xx xxx x  x xxxx
xx   xxx  xxx xxx   x  xxxxx xxx
xx   x   xx     xxx   xx  x   x
   x  xxxx xx    xxxx x x  x  x x
 x xxx  x x x   xx  x    xx  xx x
xxx  xx xx     x   x xx     xx
     x x x        x xx  xx xx  x
x  xxxx xx xx  x  x x  xxxx    xx
x x x      xxx x     xx   xxx xxx
    x xx  x xxx  x       x x   xx
    xx   x xxx xxxx x x x    x  x
xx x xxxx xx   x    x xxxxxxxxx
        x  xx xx x x   xx   xx  x
xxxxxxx xx x        xxxxx x xxx
x     x xx xx   x xxxx xx   x xx
x xxx x xx  x     xxx   xxxxx xxx
x xxx x    xx  x     xxxxxxxx xxx
x xxx x   x xx        xx    x
x     x   xxxxxxxxx x xx xx xx
xxxxxxx  x xx  x xx    x x x xx x
</code>```

For printing my qr_code I use the CairoOutputter of Barby but when I try to convert my output to svg, png,... I get the following error message:

```<code>NoMethodError (undefined method `two_dimensional?' for #<RQRCode::QRCode:0x0000000794bd88>)
</code>```

Do you have any ideas of what I can do to correct this error?

Gemfile:

```<code>gem 'rqrcode','~> 0.4.2'
gem 'barby'
gem 'cairo'
</code>```

In my model:

```<code>require 'barby'
require 'barby/outputter/cairo_outputter'
require 'rqrcode'
qr = RQRCode::QRCode.new('test')
puts  qr
outputter = Barby::CairoOutputter.new(qr).to_svg
</code>```

答:
As stated in the project README, you need to use one of the supported barcode classes. Namely, you need to use Barby::QrCode, not RQRCode::QRCode.

With the following libraries installed:

```<code>gem install 'barby'   # core library
gem install 'cairo'   # dependency for output
gem install 'rqrcode' # dependency for barcode
</code>```

The following implementation works fine:

```<code>require 'barby'
require 'barby/outputter/cairo_outputter'
require 'barby/barcode/qr_code'

qr = Barby::QrCode.new('test')
outputter = Barby::CairoOutputter.new(qr).to_svg
</code>```

Unlike RQRCode::QRCode, Barby::QrCode implements methods such as two_dimensional? and encoding - which are required by the Barby::CairoOutputter implementation.

Body:
I just want to generate a QR code using rqrcode gem. When I create my new rqrcode instance:

qr = RQRCode::QRCode.new('test')

I get the following input :

xxxxxxx  x  x x  xxxxxx x xxxxxxx
x     x xx xxxxx     xx   x     x
x xxx x   x   x xxxx  xx  x xxx x
x xxx x   x x x x  x x xx x xxx x
x xxx x  x   xxx xxx    x x xxx x
x     x xxx  x    xx      x     x
xxxxxxx x x x x x x x x x xxxxxxx
        x x     xx   x x
    xxxx  xxxxx  xxxx   x xx   x
 x  xx xxxx   xxxx xxxx    x  xxx
xx x xx   x x  xxxx            xx
  x  x x  xxx xxxxxxx x xx xxx  x
x  xxxxxxx x x x xxxx xx xx  xx
x x x         xx xxx x  x xxxx
xx   xxx  xxx xxx   x  xxxxx xxx
xx   x   xx     xxx   xx  x   x
   x  xxxx xx    xxxx x x  x  x x
 x xxx  x x x   xx  x    xx  xx x
xxx  xx xx     x   x xx     xx
     x x x        x xx  xx xx  x
x  xxxx xx xx  x  x x  xxxx    xx
x x x      xxx x     xx   xxx xxx
    x xx  x xxx  x       x x   xx
    xx   x xxx xxxx x x x    x  x
xx x xxxx xx   x    x xxxxxxxxx
        x  xx xx x x   xx   xx  x
xxxxxxx xx x        xxxxx x xxx
x     x xx xx   x xxxx xx   x xx
x xxx x xx  x     xxx   xxxxx xxx
x xxx x    xx  x     xxxxxxxx xxx
x xxx x   x xx        xx    x
x     x   xxxxxxxxx x xx xx xx
xxxxxxx  x xx  x xx    x x x xx x

For printing my qr_code I use the CairoOutputter of Barby but when I try to convert my output to svg, png,... I get the following error message:

NoMethodError (undefined method `two_dimensional?' for #<RQRCode::QRCode:0x0000000794bd88>)

Do you have any ideas of what I can do to correct this error?

Gemfile:

gem 'rqrcode','~> 0.4.2'
gem 'barby'
gem 'cairo'

In my model:

require 'barby'
require 'barby/outputter/cairo_outputter'
require 'rqrcode'
qr = RQRCode::QRCode.new('test')
puts  qr
outputter = Barby::CairoOutputter.new(qr).to_svg

Body:
As stated in the project README, you need to use one of the supported barcode classes. Namely, you need to use Barby::QrCode, not RQRCode::QRCode.

With the following libraries installed:

gem install 'barby'   # core library
gem install 'cairo'   # dependency for output
gem install 'rqrcode' # dependency for barcode

The following implementation works fine:

require 'barby'
require 'barby/outputter/cairo_outputter'
require 'barby/barcode/qr_code'

qr = Barby::QrCode.new('test')
outputter = Barby::CairoOutputter.new(qr).to_svg

Unlike RQRCode::QRCode, Barby::QrCode implements methods such as two_dimensional? and encoding - which are required by the Barby::CairoOutputter implementation.


问:
jmeter- Throughput Shaping meter Request generation
I have created a profile of maximum peak load of 5000 rps using Throughput shaping meter provided as a jmeter plugin.

When I add  "transaction per second" as a listener to analyze the request per second. It does not show a peak load of 5000rps.

Does the transaction per second listener shows the plot of generation of the request by Throughput shaping meter or the actual execution plot of those generated requests against any target server.

How can I confirm the generation of the requests reaches he maximum peak load of 5000 rps? Currently I am using http sampler for request generation.

答:
First thing first, Yes, Transaction Per Second listener shows the proper results of your generated transactions per second.

If I'm not mistaken, 5000 rps is a quite heavy load and to generate such load you have to consider some major points. I'm trying to mention those in short:

To generate 5000 requests per second, you have to provide enough number of threads to make those requests. Please do not make any confusions between threads and requests.

Higher Throughput (rps) also depends on the response time of your requests. So, if the response time is too high, I'm afraid you can't hammer your server in such rps.

Remember the machine dependency!! To get your anticipated rps, you have to run your test in Distributed architecture. Check out the JMeter best practices guidelines.

If you already did those things, then please try to use some sniffer tools like Wireshark from your application server for checking how many requests are there during your peak load time. It will match likely your transactions per second listeners results.

Now, even if you can't get those, let's tweak some server configuration like TCP connections. tcp_tw_recycle or tcp_tw_reuse, these two are usually disabled. Try to temporarily enable these configs and re-run your test to check the rps value again. You have to remember this thing that, how many ports are open during that peak load time, how many connections are open and how many are established during that time? Did you consider those things?

There are plenty of work you can do for this things!!! I just have to say, performance testing isn't done by only load testing tools, it's also the smartness and capability of performance tester.

So, I can give my two cent for today, you can re consider these things and try to redesign your test plan.

You can also check this thread: How to send 4000+ requests in exactly 1 second?

Thank you.


问:
receive http requests in rabbitmq
API sends to my app message via http POST method.

To prevent data loss while my controller is off I want to use rabbit.

how to receive http POST requests in rabbitmq?

is possible at all?

答:
No. There has to be some component which converts the requests. You also have to consider that the HTTP request requires a response. Do you respond with status 200/201 all the time, indicating "OK"/"Created"? What about errors you only discover later, when your controller is online again?

In your situation you might want to ask your users to send the data directly using RabbitMQ instead of using HTTP.

Title: receive http requests in rabbitmq


问:
Same Ajax Response after Page Reload
I am building a website where I am loading the content through an Ajax request. So when the user clicks on a link I prevent a page reload and load the content with Ajax in the main area. Now I have the problem that if the user clicks on the refresh button they will be thrown away to the very first page. Is there a way to somehow store where the user is in the page in the moment and to recall that value at a reload so that I can call the same Ajax Request the user had last?

Let me know if you need any specific code.

Thanks a lot!

David

答: You can use session or JS cookie to persist the data through user session.</p>

Title: Same Ajax Response after Page Reload


问:
Throwing exception from CompletableFuture
I have the following code:

```<code>// How to throw the ServerException?
public void myFunc() throws ServerException{
    // Some code
    CompletableFuture<A> a = CompletableFuture.supplyAsync(() -> {
        try {
            return someObj.someFunc();
        } catch(ServerException ex) {
            // throw ex; gives an error here.
        }
    }));
    // Some code
}
</code>```

someFunc() throws a ServerException. I don't want to handle this here but throw the exception from someFunc() to caller of myFunc().

答:
I think that you should wrap that into a RuntimeException and throw that:

```<code> throw new RuntimeException(ex);
</code>```

Or many be a small utility would help:

```<code>static class Wrapper extends RuntimeException {

    private Wrapper(Throwable throwable) {
        super(throwable);
    }

    public static Wrapper wrap(Throwable throwable) {
        return new Wrapper(throwable);
    }

    public Throwable unwrap() {
        return getCause();
    }
}

 public static void go() {
    CompletableFuture<String> a = CompletableFuture.supplyAsync(() -> {
        try {
            throw new Exception("Just because");
        } catch (Exception ex) {
            throw Wrapper.wrap(ex);
        }
    });

    a.join();
}
</code>```

And then you could unwrap that..

```<code> try {
        go();
 } catch (Wrapper w) {
        throw w.unwrap();
 }
</code>```

Body:
I have the following code:

// How to throw the ServerException?
public void myFunc() throws ServerException{
    // Some code
    CompletableFuture a = CompletableFuture.supplyAsync(() -> {
        try {
            return someObj.someFunc();
        } catch(ServerException ex) {
            // throw ex; gives an error here.
        }
    }));
    // Some code
}

someFunc() throws a ServerException. I don't want to handle this here but throw the exception from someFunc() to caller of myFunc().

Body:
I think that you should wrap that into a RuntimeException and throw that:

 throw new RuntimeException(ex);

Or many be a small utility would help:

static class Wrapper extends RuntimeException {

    private Wrapper(Throwable throwable) {
        super(throwable);
    }

    public static Wrapper wrap(Throwable throwable) {
        return new Wrapper(throwable);
    }

    public Throwable unwrap() {
        return getCause();
    }
}

 public static void go() {
    CompletableFuture<String> a = CompletableFuture.supplyAsync(() -> {
        try {
            throw new Exception("Just because");
        } catch (Exception ex) {
            throw Wrapper.wrap(ex);
        }
    });

    a.join();
}

And then you could unwrap that..

 try {
        go();
 } catch (Wrapper w) {
        throw w.unwrap();
 }